I don't see the point in including the table name when there's only one table. On the other hand, I always include table names when there's more than one table used in query.
Weirdan wrote:I don't see the point in including the table name when there's only one table. On the other hand, I always include table names when there's more than one table used in query.
However, if you're lazy and you have several tables, you can use aliases.
s it better/worse/pointless for including the table name in the sql statement as a standard, even if not lisiting for an inner join
More intrested in, if i was to create a standard for the company i work for, would you recommend I suggest to use the tablename.fieldname or just fieldname.
In regard to aliases, we see no point including this as we have properly formatted table structures.
Slyvampy wrote:In regard to aliases, we see no point including this as we have properly formatted table structures.
That's not the point. It just saves you the work of having to type/paste the table name every time.
Common practice is designating a single letter for each table.
It can be a lot easier to read if done properly, and a lot harder if done poorly.
SELECT `q`.`id` as `mainID`, `q`.`section`, `q`.`fieldType`, `a`.`qid`, `a`.`uid`, `a`.`answer` as `mainAnswer`
FROM `gradlife_-_gradlife`.`questions` as `q`, `gradlife_gradlife`.`answers` as `a`
WHERE`q`.`id` = `a`.`qid` AND `q`.`section` = '2'
GROUP BY `q`.`id`, `a`.`uid` ORDER BY `a`.`uid`"
There is no better way than aliases. Whenever you are dealing with more than one table that too particularly in JOIN statements, aliases save a lot of work and they are pretty clear and recognizable as well.