SQL supports qualifying a column by prefixing the reference with either the full table name:
SELECT tbl_names.id, tbl_section.id, name, section FROM tbl_names JOIN tbl_section ON tbl_section.id = tbl_names.id
…or a table alias:
SELECT n.id, s.id, n.name, s.section FROM tbl_names n JOIN tbl_section s ON s.id = n.id
The table alias is the recommended approach — why type more than you have to?
Why Do These Queries Look Different?
Secondly, my answers use ANSI-92 JOIN syntax (yours is ANSI-89). While they perform the same, ANSI-89 syntax does not support OUTER joins (RIGHT, LEFT, FULL). ANSI-89 syntax should be considered deprecated, there are many on SO who will not vote for ANSI-89 syntax to reinforce that. For more information, see this question.
Related Posts:
- 1052: Column ‘id’ in field list is ambiguous
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]
- How do I restore a dump file from mysqldump?
- difference between primary key and unique key
- How to do a batch insert in MySQL
- Error: Duplicate entry ‘0’ for key ‘PRIMARY’
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- How can I do a FULL OUTER JOIN in MySQL?
- Cannot delete or update a parent row: a foreign key constraint fails
- Cannot delete or update a parent row: a foreign key constraint fails
- Rename a column in MySQL
- Cannot delete or update a parent row: a foreign key constraint fails
- How do I import an SQL file using the command line in MySQL?
- #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
- Authentication plugin ‘caching_sha2_password’ cannot be loaded
- When to use SELECT … FOR UPDATE?
- SQL Query Where Field DOES NOT Contain $x
- What is the difference between JOIN and UNION?
- Create a new database with MySQL Workbench
- MySQL Multiple Joins in one query?
- Error Code: 2013. Lost connection to MySQL server during query
- Column ‘user_id’ in field list is ambiguous
- How to join two tables by multiple columns in SQL?
- How to get size of mysql database?
- Selecting data from two different tables without using joins
- MySQL: Invalid use of group function
- Creating a search form in PHP to search a database?
- Simple Random Samples from a Sql database
- What does SQL clause “GROUP BY 1” mean?
- SQL ZOO List each continent and the name of the country that comes first alphabetically
- How can I prevent SQL injection in PHP?
- Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root
- Generating a random & unique 8 character string using MySQL
- SQL select only rows with max value on a column
- Unknown Column In Where Clause
- Repair all tables in one go
- MySQL equivalent of DECODE function in Oracle
- How to create a foreign key in phpmyadmin
- How to check if mysql database exists
- Join vs. sub-query
- #1062 – Duplicate entry for key ‘PRIMARY’
- Is there a Profiler equivalent for MySql?
- Remove Primary Key in MySQL
- MySQL: Cloning a MySQL database on the same MySql instance
- Is merge statement available in MySQL
- How to get the count of each distinct value in a column?
- Data is not constantly loading from custom wordpress table
- How do you properly prepare a %LIKE% SQL statement?
- Optimize WordPress Query that take 5 seconds to execute
- Getting wrong relationship value in $args in wp_Query?
- “#1067 – Invalid default value for ‘post_date'” when trying to reset AI after backup
- Inserting Post Meta From SQL
- Extending the database
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- Size article thumbnails and retrieve them directly from database
- SQL Error wp_commentmeta – incorrect table definition
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Database Tables Lost Indexes? How to Recover?
- SQL Database, repeated tables?
- Create table from array with prepare
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- Code to remove authors with no posts connected to them
- SQL command to convert all tags in lowercase?
- SQL Query in WordPress – Getting Impossible WHERE error
- Why this query is not showing any result on wordpresss home page?
- Using AND and bracket grouping in SQL not working
- Why does changing Database Table Prefixes result in loss of content?
- WP MultiSite: Can’t select database error after changing to new domain
- How can I write a formal sql query to get data from a custom table
- $wpdb->get_var – What value is returned when zero records are found?
- Data is not constatntly loading from custom wordpress table
- Lock wait timeout exceeded; try restarting transaction
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- SQL query to change custom field in WordPress database
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How to create index (sql) to a meta_key?
- Improving performance of SQL sub-queries in WordPress
- Delete all users meta that named: user_avatar
- An SQL query to find orphaned image attachments and their meta
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- Display MySQL as part of a Page
- $wpdb post type and term query only works when there are no dashes or spaces in the term slug and title
- can’t delete a row from post_meta table
- get_results() query not working only when entering strings
- SQL error on restoring database
- optimise SQL wordpress call
- Query sql for truncate post_content in wp_posts table
- Woocommerce: Grab total revenue of a product over all orders
- export individual posts to text files or a single csv file
- SQL query : Select a thumbnail for a media
- SQL – Pull products of particular category from a remote WordPress woocommerce db
- why you don’t Implement PDO for access every thing to database
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- How do I load a sql.gz file to my database? (importing)
- Possible SQL injection. How to locate and fix?