About 1,610,000 results
Open links in new tab
  1. Mysql subquery result in "where" clause - Stack Overflow

    Dec 21, 2011 · A subquery is a SELECT statement within another statement. Starting with MySQL 4.1, all subquery forms and operations that the SQL standard requires are supported, as well as a few features that are MySQL-specific.

  2. Selecting multiple columns/fields in MySQL subquery

    Apr 16, 2011 · So the question part. Is there a way to get multiple columns from a single subquery or should I use two subqueries (MySQL is smart enough to group them?) or is joining the following way to go: [[attribute to language] to translation] (joining 3 tables seems like a worse performance than subquery).

  3. mysql - How to SELECT based on value of another SELECT - Stack …

    I have a table that looks something like this: Name Year Value A 2000 5 A 2001 3 A 2002 7 A 2003 1 B 2000 6 B 2001 1 B 2002 ...

  4. mysql - Solution to "subquery returns more than 1 row" error

    Jan 27, 2015 · SELECT * FROM Students WHERE Marks = (SELECT MAX(Marks) FROM Students) --Subquery returns only 1 value SELECT * FROM Students WHERE Marks IN (SELECT Marks FROM Students ORDER BY Marks DESC LIMIT 10) - …

  5. MySQL: View with Subquery in the FROM Clause Limitation

    It works fine on mysql 5.0.45, without much of a speed penalty (compared to executing the original sub-query select without any views). Share Improve this answer

  6. SUM(subquery) in MYSQL - Stack Overflow

    Jan 6, 2012 · Another solution is to enclose the subquery in additional parentheses. SELECT m.col1, SUM((SELECT col5 FROM table WHERE col2 = m.col1)) FROM table AS m In my case this solved it. Also the MySQL documentation (13.2.15 Subqueries) says: A subquery must always appear within parentheses.

  7. mysql if function - subquery as a condition - Stack Overflow

    Dec 12, 2012 · I believe the following query is self explanatory: SELECT IF (SELECT COUNT(*) FROM mytable > 0, 'yes', 'no'); Why doesn't it work? And how should I correct it?

  8. How do you use the "WITH" clause in MySQL? - Stack Overflow

    MySQL prior to version 8.0 doesn't support the WITH clause (CTE in SQL Server parlance; Subquery Factoring in Oracle), so you are left with using: TEMPORARY tables; DERIVED tables ; inline views (effectively what the WITH clause represents - they are interchangeable) The request for the feature dates back to 2006.

  9. mysql - WHERE value IS NOT IN (subquery) - Stack Overflow

    May 7, 2025 · Using inner or sub query is expensive when you have big data. use joins instead, lets learn converting subquery to join. With Subquery We had: Select distinct Customer from orders where customer not in (SELECT distinct Customer FROM Orders where invoice in (Select distinct invoice from Promotions where Coupon='couponA')); Converting sub-query ...

  10. mysql - subquery in select statement vs subquery in FROM …

    Jun 1, 2021 · What you are describing as a "subquery in the SELECT clause is a scalar subquery. The value is a replacement for a literal value, so it can only return one column. If the scalar returns zero rows, then the value is NULL. Note that scalar subqueries are sometimes extended to support multiple columns.

Refresh