在写入mysql数据库之前更改字符串 [英] Change string before writing into mysql database

查看:159
本文介绍了在写入mysql数据库之前更改字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello CodeProject,



目前我正在为房东/小人写一个应用程序。

我创建了一个表列Muell,定义为十进制(6,2)。

我正在使用带有

Hello CodeProject,

currently i'm writing an app for an landlord/lesser.
I have created a table which have a column "Muell", defined as decimal(6,2).
I'm using an Inputfield with

SELECT distinct CONCAT(e.Miete, " €") AS Miete,

作为默认内容。如果用户更改字段,并留下€,我将遇到错误。



我正在使用该声明:



as default content. If the user changes the field, and leaves the "€" i'm running into an error.

I'm using that statement:

UPDATE tbl_nebenkosten
    SET Muell = '$Muell',
        Wasser = '$Wasser',
        Versicherung = '$Versicherung',
        Strom = '$Strom',
        Hausverwaltung = '$Hausverwaltung',
        Heizung = '$Heizung'
    WHERE MieterID = '${state.MieterID}'





我读过 MySQL SUBSTRING_INDEX()函数 - w3resource [ ^ ]。在那个页面上只给出了一个带有SELECT的例子。



在我的情况下我需要UPDATE。

可悲的是我刚刚开始编程使用SQL,对我来说很多都是新的。



我尝试了什么:





I read MySQL SUBSTRING_INDEX() function - w3resource[^]. On that page just a example with "SELECT" is given.

In my case i need UPDATE instead.
Sadly i just started programming with SQL, so many is new for me.

What I have tried:

UPDATE tbl_nebenkosten
    SET Müll = SELECT SUBSTRING_INDEX('$Muell',' ',1)
        Wasser = '$Wasser',
        Versicherung = '$Versicherung',
        Strom = '$Strom',
        Hausverwaltung = '$Hausverwaltung',
        Heizung = '$Heizung'
    WHERE MieterID = '${state.MieterID}'





那个给我一个错误。



That one gives me an error.

推荐答案

Muell',
Wasser = '
Muell', Wasser = '


Wasser',
Versicherung = '
Wasser', Versicherung = '


Versicherung',
Strom = '
Versicherung', Strom = '


这篇关于在写入mysql数据库之前更改字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆