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 ? 8 1820
*** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 15:58:19 +0100): 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 ?
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" <al******************@telecomputeronline.com> a écrit
dans le message de news: fw*****************************@40tude.net... *** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 15:58:19 +0100): 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 ?
Which ModelName column do you mean? You have two.
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 wrote/escribió (Tue, 8 Feb 2005 16:50:33 +0100): Which ModelName column do you mean? You have two.
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 ?
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
--
"Alvaro G Vicario" <al******************@telecomputeronline.com> a écrit
dans le message de news: hx****************************@40tude.net... *** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 16:50:33 +0100): Which ModelName column do you mean? You have two.
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 ?
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.
FANTASTIC !!!! thanks a lot !
Bob Bedford wrote: 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 ? Which ModelName column do you mean? You have two.
I need one column only ! in some cases the ModelName comes from table model1, sometimes from model2.
Somehow, I have a feeling your data model needs revision...
It's there any way to create only one column?
If you need one column only, then you should define one column
only. Something like this:
SELECT CONCATENATE(model1.Name, model2.Name, model3.Name,
shmodel.shmodelname) as ModelName, ...
Cheers,
NC
>> I need one column only ! in some cases the ModelName comes from table model1, sometimes from model2.
Somehow, I have a feeling your data model needs revision...
Not so easy: let's explain. I've a database coming from a company. Some
datas aren't available in this DB, and I've to create some items myself. I
can't do it on the other company's DB as the record are dropped regularly
and filled with new datas (updates, new items, etc). So I need to have 2
tables, one with the company's datas, and one with mine. It's there any way to create only one column?
If you need one column only, then you should define one column only. Something like this:
SELECT CONCATENATE(model1.Name, model2.Name, model3.Name, shmodel.shmodelname) as ModelName, ...
Concatene seems to fail if any items is NULL.
Bob Bedford wrote: "Alvaro G Vicario" <al******************@telecomputeronline.com> a écrit dans le message de news: hx****************************@40tude.net...
*** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 16:50:33 +0100):
Which ModelName column do you mean? You have two.
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 ?
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.
FANTASTIC !!!! thanks a lot !
Even better, try the Coalesce(list) function.
Your SELECT then becomes:
SELECT COALESCE(model1.Name, model2.Name, model3.Name, shmodel.shmodelname)
as ModelName, ...
Coalesce(list) takes the first non-NULL in the list.
CJP
--
Christopher J Pomasl Suse Linux 9.0
Senior Software Engineer Starband 360 4/68
Computer Associates SPEBSQSA, Lead/Bari, SOR
IBM Certified Specialist - DB2 UDB V6/V7 User
IBM Certified Solutions Expert - DB2 V7 Family Application Development
IBM Certified Solutions Expert - DB2 UDB Database Administration for OS/390
Always remember, you are unique...just like everyone else.
"pomasl<nospam> @starband.net>" <"pomasl<nospam> a écrit dans le message de
news: 85**************@fe25.usenetserver.com... Bob Bedford wrote: "Alvaro G Vicario" <al******************@telecomputeronline.com> a écrit dans le message de news: hx****************************@40tude.net...
*** Bob Bedford wrote/escribió (Tue, 8 Feb 2005 16:50:33 +0100):
> Which ModelName column do you mean? You have two.
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 ?
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.
FANTASTIC !!!! thanks a lot !
Even better, try the Coalesce(list) function. Your SELECT then becomes:
SELECT COALESCE(model1.Name, model2.Name, model3.Name, shmodel.shmodelname) as ModelName, ...
Great ! thanks for info. Probably I'm not the only one to find this useful.
Cheers This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: user mysql |
last post by:
HELLO FRIENDS. HERE A FANTASTIC NEWS FOR MYSQL WINDOWS USER. READE
THIS.
The article is grab from www/internetnews/com/
DO YOU THINK THAT IS A GOOD NEWS ?
-----------------------------------------------------------------------------
Open source database server company MySQL's next production release of
its open source MySQL database server...
|
by: George Augustino |
last post by:
REQUEST FOR DISCUSSION (RFD)
unmoderated group comp.databases.mysql
Newsgroup line:
comp.databases.mysql MySQL relational database system discussion group.
This is a formal Request For Discussion (RFD) for the creation of a
world-wide unmoderated Usenet newsgroup comp.databases.mysql.
This is not a Call for Votes (CFV); you cannot vote...
|
by: s a n j a y |
last post by:
Hi All,
I am want to upgrade MySQL from 4.0 to 4.1 on linux. The reason being the
subqueries.
Problem is
Failed dependencies:
libcrypto.so.0.9.6 is needed by MySQL-Max-4.1.0-0
libssl.so.0.9.6 is needed by MySQL-Max-4.1.0-0
|
by: blizeach |
last post by:
The problem is that when I installed Slackware I told it to install
MySQL. I thought it did so. I looked around and found in the
directory /etc/rc.d/ a file called rc.mysqld.new wich I read.
It said to make this file executable so that it would start the
daemon at system boot. I made it executable. Needless to say it didn't
work.
So I read a...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
| |
by: Saqib Ali |
last post by:
I have set up MySQL on my machine and can successfully use it.
However, I'm trying to set up TOra so that I can browse the databases
effectively. I'm having lots of trouble trying to get TOra to work
with MySQL.
Please take a look at the notes below and please let me know why I'm
having trouble and how to fix it.....
Thanks
-Saqib
|
by: Nick |
last post by:
hi, all
I have a red hat 9 and looks like it had mysql 3.2.54 installed before,
but, actually not, i can not find the install folder and I can not
uninstall it. So I am trying to install/upgrade to 4.1, but, still can
not get it work.
Here is what I did:
# rpm -Uvh
MySQL-server-standard-4.1.14-0.rhel4.i386.rpm
warning:...
|
by: Richard Petty |
last post by:
Today I began preparations for upgrading MySQL. I downloaded the binary RPMs for
Red Hat Enterprise 4 (we're running CentOS, a clone) for MySQL 5.0.13 from the
MySQL AB web site. Running a test, I got this:
rpm -hUv MySQL* --test
warning: MySQL-client-standard-5.0.13-0.rhel4.i386.rpm: V3 DSA signature: NOKEY,
key ID 5072e1f5
error: Failed...
|
by: Good Man |
last post by:
Hi there
I've noticed some very weird things happening with my current MySQL setup
on my XP Laptop, a development machine.
For a while, I have been trying to get the MySQL cache to work. Despite
entering the required lines to "my.ini" (the new my.cnf) through notepad
AND MySQL Administrator, the cache does not work.
So, today I took a...
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to
communicate with a MySQL database table on a web server, from inside
of my company's Access-VBA application. I know VBA pretty well but
have never...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |