Hi again, well, I already solved the first problem: I can simply add an "AS" part to the fields as I do to the tables.
But I am still lacking the second one... how do I make an "AND" condition optional, or how can I rewrite this in the best way? Kind regards, Arne On 24 Nov., 20:35, Arne-Kolja Bachstein <[EMAIL PROTECTED]> wrote: > Hi, > I have a small problem to solve and i am not that good in creating > more complex statements... so if anyone could help... :-) > > I have 4 tables and each has a field "MyField". Now I would like to do > something like the following: > > SELECT tbl1.id, tbl2.id, tbl3.id, tbl4.id > FROM table1 AS tbl1, table2 AS tbl2, table3 AS tbl3, table4 AS tbl4 > WHERE tbl1.MyField = 'aaa' > AND tbl2.MyField = 'bbb' > AND tbl3.MyField = 'ccc' > AND tbl3.MyField = 'ddd'; > > But instead of this (working) version I want the result field names > named differently (so I don't have 4 times 'id') and the > tbl2,tbl3,tbl4 queries should be optional... so if one of the three > tables dont have the corresponding entry, it should still return the > rest of the query. > > Don't know how to better describe it, I hope you know what I mean. I > would do it in 4 single queries usually, but it's an import script > that queries the database hundrets of times... > > Kind regards > > Arne --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "mysql" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mysql -~----------~----~----~----~------~----~------~--~---
