![]() ![]() You'll get the columns in the order they're listed in the query. The only caveat is if you don't name your columns and instead use SELECT * like the following: SELECT * While you're at it, use logical table aliases. It's also convention to put the joined table's column first in the ON clause. In fact, assuming proper indexes, MySQL will most likely start with the table that has the WHERE clause because it narrows down the result set, and MySQL likes to start with the set that has the fewest rows. While it makes no difference (performance wise) to MySQL which order you put the tables in with INNER JOIN (MySQL treats them as equal and will optimize them the same way), it's convention to put the table that you are applying the WHERE clause to first. ![]() You should consider formatting your JOIN in this format, using the WHERE clause, and proper capitalization: SELECT p.postsTitle Instead of the following: select a.postsTitle Notice, I have table bookmarks put first here. Or should I do it like: select b.postsTitle ![]() But, since I'm selecting based on whats there in bookmarks, is it necessary I declare the table bookmarks first instead of post in the sql statement? Will doing it the way I'm doing it cause and problems in data selection or efficiency? Notice, I have the table posts put first before the table bookmarks. My sql is currently like this: select a.postsTitle This is the table based on which posts will be selected from the posts table, to display to the user. The main table which holds the ids of the posts a user has bookMarked, is called bookMarks. I'm selecting data to output posts a user has book marked. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |