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’
- Case statement in MySQL
- Cannot delete or update a parent row: a foreign key constraint fails
- #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
- When to use SELECT … FOR UPDATE?
- What is the difference between JOIN and UNION?
- Create a new database with MySQL Workbench
- Error Code: 2013. Lost connection to MySQL server during query
- 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
- Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root
- SQL select only rows with max value on a column
- 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
- How can I search (case-insensitive) in a column using LIKE wildcard?
- importing a CSV into phpmyadmin
- How to check if mysql database exists
- Join vs. sub-query
- 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
- What SQL Query to do a simple find and replace
- What’s a good strategy for planning WordPress DB growth?
- Scanning Database for malicious Data
- wpdb->prepare function remove single quote for %s in SQL statment
- How to Join two tables from separate databases within WordPress
- 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?
- 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
- Code to remove authors with no posts connected to them
- 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
- How to get INSERT errors from $wpdb?
- SQL query to set posts in bulk based on the post content
- MySQL query for taxonomy-meta
- How can I write a formal sql query to get data from a custom table
- latency problems with wordpress install (from SQL import)
- DB prefix not updating
- Performing CRUD operations on front end in wordpress
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- Find locations of all featured images of draft posts via SQL
- SQL query to change custom field in WordPress database
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How to show result of sql query in a page?
- update_option returns false in AJAX, how to debug?
- How to create index (sql) to a meta_key?
- Improving performance of SQL sub-queries in WordPress
- The function is deprecated; use mysql_real_escape_string() instead
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- WPDB delivers wrong results from complex queries
- How to change link in all posts?
- Display MySQL as part of a Page
- get_results() query not working only when entering strings
- Query sql for truncate post_content in wp_posts table
- Woocommerce: Grab total revenue of a product over all orders
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- Delete posts with word count less than x number of words
- SQL query : Select a thumbnail for a media
- SQL command to export post_content from wp_posts using phpMyAdmin
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- SQL get last entry of a specific gravity form
- How do I load a sql.gz file to my database? (importing)