需要mysql帮助 [英] mysql help needed

查看:70
本文介绍了需要mysql帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多链接可能的查询:


SELECT model1.Name作为ModelName,model2.Name作为ModelName,model3.Name作为

ModelName,shmodel.shmodelname为ModelName,...

如果我然后尝试按ModelName命令,则查询失败(未知
$ b ''order子句''中的$ b列''ModelName'')。有什么想法吗?

I''ve a query with multiple link possibilities:

SELECT model1.Name as ModelName, model2.Name as ModelName, model3.Name as
ModelName, shmodel.shmodelname as ModelName, ...

If I then try to do a "order by ModelName", then the query fails (Unknown
column ''ModelName'' in ''order clause''). Any idea ?

推荐答案

*** Bob Bedford写道/escribió(星期二,2005年2月8日15:58:19 +0100):
*** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 15:58:19 +0100):
SELECT model1.Name as ModelName,model2.Name as ModelName
[...]如果我然后尝试执行按ModelName排序,则查询失败(未知
''order clause''中的列''ModelName'')。有什么想法?
SELECT model1.Name as ModelName, model2.Name as ModelName [...] If I then try to do a "order by ModelName", then the query fails (Unknown
column ''ModelName'' in ''order clause''). Any idea ?




你的意思是哪个ModelName专栏?你有两个。

-

- álvaroG。Vicario - 西班牙布尔戈斯

- 谢谢你没有给我发电子邮件你的问题

-



Which ModelName column do you mean? You have two.
--
-- álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--


" Alvaro G Vicario" <人****************** @ telecomputeronline.com> aécrit

dans le message de news:fw*****************************@40tude.net ...
"Alvaro G Vicario" <al******************@telecomputeronline.com> a écrit
dans le message de news: fw*****************************@40tude.net...
*** Bob Bedford写道/escribió(星期二,2005年2月8日15:58:19 +0100):
*** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 15:58:19 +0100):
SELECT model1.Name as ModelName,model2 .Name作为ModelName
SELECT model1.Name as ModelName, model2.Name as ModelName


[...]


[...]

如果我尝试按ModelName执行order,则查询失败(Unknown
列''order clause''中的'ModelName'')。有什么想法吗?
If I then try to do a "order by ModelName", then the query fails (Unknown
column ''ModelName'' in ''order clause''). Any idea ?



你的意思是哪个ModelName专栏?你有两个。



Which ModelName column do you mean? You have two.




我只需要一列!在某些情况下,ModelName来自表格

model1,有时来自model2。它有没有办法只创建一个列




I need one column only ! in some cases the ModelName comes from table
model1, sometimes from model2. It''s there any way to create only one column
?


*** Bob Bedford写道/escribió(2005年2月8日星期二) 16:50:33 +0100):
*** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 16:50:33 +0100):
您的意思是哪个ModelName列?你有两个。
Which ModelName column do you mean? You have two.



我只需要一个专栏!在某些情况下,ModelName来自表
model1,有时来自model2。它有没有办法只创建一列



I need one column only ! in some cases the ModelName comes from table
model1, sometimes from model2. It''s there any way to create only one column
?




尝试使用IFNULL()函数加入:

IFNULL(expr1,expr2)


如果expr1不为NULL,则IFNULL()返回expr1,否则返回expr2。

IFNULL( )返回一个数字或字符串值,具体取决于

中使用的上下文。


-

- álvaroG。Vicario - 西班牙布尔戈斯

- 感谢您不通过电子邮件将我的问题发送给我

-



Try a join with the IFNULL() function:

IFNULL(expr1,expr2)

If expr1 is not NULL, IFNULL() returns expr1, else it returns expr2.
IFNULL() returns a numeric or string value, depending on the context in
which it is used.

--
-- álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--


这篇关于需要mysql帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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