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”?
- 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
- Case statement in MySQL
- 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’
- How do I quickly rename a MySQL database (change schema name)?
- What does SQL Select symbol || mean?
- What is the definition of cardinality in SQL
- 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?
- mysql Foreign key constraint is incorrectly formed error
- Selecting data from two different tables without using joins
- how to drop partition without dropping data in MySQL?
- MySQL: Invalid use of group function
- Creating a search form in PHP to search a database?
- Getting “Lock wait timeout exceeded; try restarting transaction” even though I’m not using a transaction
- Simple Random Samples from a Sql database
- ERROR 1452: Cannot add or update a child row: a foreign key constraint fails
- 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
- SQL statement not working – “Operand type clash: date is incompatible with int’
- Convert partially non-numeric text into number in MySQL query
- Repair all tables in one go
- MySQL equivalent of DECODE function in Oracle
- How can I search (case-insensitive) in a column using LIKE wildcard?
- How to create a foreign key in phpmyadmin
- importing a CSV into 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?
- ERROR 1115 (42000): Unknown character set: ‘utf8mb4’
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- Remove Primary Key in MySQL
- select * from table where column = something or, when unavailable, column = something else
- 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?
- What SQL Query to do a simple find and replace
- What’s a good strategy for planning WordPress DB growth?
- Optimize WordPress Query that take 5 seconds to execute
- Scanning Database for malicious Data
- Getting wrong relationship value in $args in wp_Query?
- wpdb->prepare function remove single quote for %s in SQL statment
- “#1067 – Invalid default value for ‘post_date'” when trying to reset AI after backup
- Inserting Post Meta From SQL
- How to Join two tables from separate databases within WordPress
- Extending the database
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- How to execute mulitple statement SQL queries using $wpdb->query?
- 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
- wpdb_prepare with multiple or condition
- How do I find which articles are missing a featured image in The WordPress database?
- SQL Error wp_commentmeta – incorrect table definition
- How to find meta entries with their posts missing via SQL?
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- How do I get the posts within a certain year/date(with sql query)?
- 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?
- Which is better and faster ? WordPress Queries or SQL Query
- 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?
- How to get INSERT errors from $wpdb?