You could also try EXISTS:
SELECT EXISTS(SELECT * FROM table1 WHERE ...)
and per the documentation, you can SELECT anything.
Traditionally, an EXISTS subquery starts with SELECT *, but it could begin with SELECT 5 or SELECT column1 or anything at all. MySQL ignores the SELECT list in such a subquery, so it makes no difference.
Related Posts:
- MySQL INSERT INTO table VALUES.. vs INSERT INTO table SET
- What’s the best way to search for a UPC code in a Database?
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- Unknown column in ‘field list’ error on MySQL Update query
- Unknown column in ‘field list’ error on MySQL Update query
- MySQL – Operand should contain 1 column(s)
- When should I use CROSS APPLY over INNER JOIN?
- MySQL “CREATE TABLE IF NOT EXISTS” -> Error 1050
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL create table if not exists and insert record only if table was created
- How do I use properly CASE..WHEN in MySQL
- How can I do a FULL OUTER JOIN in MySQL?
- MySQL query String contains
- What’s the difference between VARCHAR and CHAR?
- Case statement in MySQL
- How to declare a variable in MySQL?
- MySQL Cannot Add Foreign Key Constraint
- How to split the name string in mysql?
- How do I import an SQL file using the command line in MySQL?
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
- mysql Foreign key constraint is incorrectly formed error
- MySQL: Invalid use of group function
- How can I return pivot table output in MySQL?
- Compare dates in MySQL
- MySQL “WITH” clause
- MySQL Multiple Joins in one query?
- Error Code: 2013. Lost connection to MySQL server during query
- MySQL syntax for Join Update
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
- how to drop partition without dropping data in MySQL?
- MySQL combine two columns into one column
- Simple way to calculate median with MySQL
- Error 1046 No database Selected, how to resolve?
- MySQL Error 1264: out of range value for column
- Count(*) vs Count(1) – SQL Server
- Remove duplicate rows in MySQL
- How to SUM and SUBTRACT using SQL?
- Cast from VARCHAR to INT – MySQL
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- How do you force mysql LIKE to be case sensitive?
- MySQL – UPDATE multiple rows with different values in one query
- How to create a MySQL hierarchical recursive query?
- ERROR 1148: The used command is not allowed with this MySQL version
- Insert into a MySQL table or update if exists
- How to round down to nearest integer in MySQL?
- MySQL starts with searching issue
- Query to convert from datetime to date mysql
- Is it possible to GROUP BY multiple columns using MySQL?
- MySQL error: key specification without a key length
- Check if MySQL table exists without using “select from” syntax?
- MySQL equivalent of DECODE function in Oracle
- mysql update column with value from another table
- The used SELECT statements have a different number of columns
- How to delete from multiple tables in MySQL?
- MySQL: Can’t create table (errno: 150)
- How to copy a row and insert in same table with a autoincrement field in MySQL?
- Join vs. sub-query
- Alternative to except in MySQL
- Equivalent of explode() to work with strings in MySQL
- ROW_NUMBER() in MySQ
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- MySQL OPTIMIZE all tables?
- MySQL – Get row number on select
- MySQL error: Unknown column in ‘where clause’
- How to truncate the text returned for a column in a MySQL query
- Using union and order by clause in mysql
- MySQL LIKE IN()?
- What’s the best way to dedupe a table?
- WP Optimization: Removing Orphaned wp_options (especially the autoload ones)
- Debugging WordPress
- This SQL request call all time and overload my server : SELECT meta_value FROM wp_sitemeta WHERE meta_key = ‘wp_installer_network’ AND site_id = 1
- Using group by on multiple columns
- “ORA-01438: value larger than specified precision allowed for this column” when inserting 3
- How can I do ‘insert if not exists’ in MySQL?
- What does Include() do in LINQ?
- SQL Server “cannot perform an aggregate function on an expression containing an aggregate or a subquery”, but Sybase can
- Get everything after and before certain character in SQL Server
- WordPress SQL LIKE request doesn’t work for fields with special symbols
- Concurrent / simultaneous MySQL connections
- WordPress plugin overloading with tmp tables
- WordPress SQL Issue not returning correct reselts
- Inner Join user tables to select users with roles
- $wpdb->prepare with LIKE returning blank array instead of rows
- Removing posts by sql
- Why line returns are not reapply after doing esc_sql?
- Show Mysql table elements as pages in WordPress
- Minimize Performance Issues of MultiSite Large Number of Tables Created
- Data is not constatntly loading from custom wordpress table
- Search results sort order failing: set by date only
- Delete oldest wordpress post (SQL query)
- Delete all users meta that named: user_avatar
- An SQL query to find orphaned image attachments and their meta
- Bulk Change WordPress category Slug
- Performance of wp_get_attachment_image_srcset() and wp_get_attachment_image_url()
- optimise SQL wordpress call
- SQL to transform all email addresses in my DB in lowercase [closed]
- Get all the related data from WordPress DB
- How to write inner join using posts_clauses?
- why you don’t Implement PDO for access every thing to database
- Deleting WordPress posts and media files based on author via MYSQL database