* Peter Engström > I have an table called 'list' where I store all items for the pulldown > menues on my site. > > Table list has three columns > - id (int autoincrement) > - pulldown_name (tinytext - name of pulldown) > - item (tinytext - the item for the pulldown menu) > > A table called client_index stor all the info about a client. > I want to load the relation data for a client but do not know how to > write the right SQL phrase. > > I've tried with this: > > SELECT > client_index.companyName, > link1.item, > link2.item > FROM > client_index > LEFT JOIN > list As link1 ON client_index.classificationID=link1.id) > LEFT JOIN > list AS link2 ON client_index.industryID=link2.id) > WHERE > client_index.id=1046 > > > When I run the SQL, I get: > > | Thecompany | Building & Construction | Building & Construction | > > With other word, link1.item, link2.item become the same, why??
Because they have the same name. This will not happen if you run the query from the mysql client, only when you run it through the client API using a language like php. Try aliasing the column names, something like this: SELECT client_index.companyName, link1.item AS classification, link2.item AS industry FROM client_index LEFT JOIN list As link1 ON client_index.classificationID=link1.id) LEFT JOIN list AS link2 ON client_index.industryID=link2.id) WHERE client_index.id=1046 -- Roger sql --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php