vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| > Do you mean that I should replace SELECT * FROM > with SELECT field1, [field2],[...] FROM? Yes. > If so, I need to specify the table name like SELECT > Clients.Name correct? You only need to do that when 2 tables have the same column name. In general, though, it's good practice to always include the table name when joining multiple tables. > Also, how can I access to Quotes.QuoteID and Products.QuoteID? Use aliases (which can be anything; I'm just replacing the '.' with a '_' below) SELECT Quotes.QuoteID AS Quotes_QuoteID, Products.QuoteID AS Products_QuoteId FROM ... Thnx, Chris |
| ||||
| From Chris, >> Do you mean that I should replace SELECT * FROM with SELECT field1, >> [field2],[...] FROM? >> > Yes. > >> If so, I need to specify the table name like SELECT Clients.Name >> correct? >> > You only need to do that when 2 tables have the same column name. In > general, though, it's good practice to always include the table name > when joining multiple tables. > >> Also, how can I access to Quotes.QuoteID and Products.QuoteID? >> > Use aliases (which can be anything; I'm just replacing the '.' with a > '_' below) > > SELECT > Quotes.QuoteID AS Quotes_QuoteID, > Products.QuoteID AS Products_QuoteId > FROM > ... > Thnx, > Chris After Olexandr Melnyk proposition to specify all the fields instead of SELECT * FROM and after Chris Boget letting me know how to have multiple columns with the same name from different tables by using aliases, I've been able to accomplish what I want! However, after having it working correctly, I've noticed that I was no using 3 or maybe 4 columns of each table so, in the columns list I've only set those that I needed. By doing that, I stopped the need for aliases (since I'm only including Quotes.QuoteID and not including Products.QuoteID) and I can still reffer to the columns by their real name. Anyway, i'ts allways good to know that aliases exist, what they are and what they're for. So, for now I'll say thank you all and I'll probably come back. Thanks, Nuno |