You are here: Re: MYSQL select question « PHP Programming Language « IT news, forums, messages
Re: MYSQL select question

Posted by Dave on 05/23/05 18:58

Thanks Geoff,

Did you mean:
SELECT table_1.ID, table_1.NAME if(table_1.ID = table_2.ID, table_2.FLAG, 0)
AS MY_FLAG
FROM table_1, table_2
WHERE table_1.ID LIKE '1000%' and table_1.ID = table_2.ID
ORDER BY table_1.ID;

If so this works but won't return the row:
10003 10002 name 0

As the query is restricted by matching ID cols in both tables.

Thanks,

Dave

"Geoff May" <BeateUndGeoff@t-online.de> wrote in message
news:d6stmv$qi3$04$2@news.t-online.com...
> Dave wrote:
> > Hi,
> >
> > [snipped]
> >
> > if I try the following query, it returns incorrect cols for rows:
> > SELECT table_1.ID, table_1.NAME if(table_1.ID = table_2.ID,
table_2.FLAG, 0)
> > AS MY_FLAG
> > FROM table_1, table_2
> > WHERE table_1.ID LIKE '1000%' ORDER BY table_1.ID;
> >
> > returns:
> > ID NAME MY_FLAG
> > 10001 10001 name 1
> > 10001 10001 name 0
> > 10002 10002 name 0
> > 10003 10002 name 0
>
> SELECT table_1.ID, table_1.NAME if(table_1.ID = table_2.ID, table_2.FLAG,
0)
> AS MY_FLAG
> FROM table_1, table_2
> WHERE table_1.ID LIKE '1000%' ORDER BY table_1.ID
> and table_1.ID = table_2.ID;
>
> MfG
>
> Geoff.
>
> --
> Unofficial F1 Database: http://glibs.ssmmdd.co.uk/
> Update: 22nd May, 2005
> USENET Email address is a spam trap, send Emails to address in the DB

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация