MySQL SubQuery - MySQL 3.23

前端 未结 4 1851
南旧
南旧 2021-01-25 00:45

I\'ve 2 tables, emp_master and passport_details.

emp_master(emp_id,first_name,email_id,dob,doj,status.........)
passport_details(id, emp_id,passport_number,given         


        
相关标签:
4条回答
  • 2021-01-25 00:55

    1.) Subqueries were added in MySQL 4.1 SubQuery in MySQL

    You can rewrite your query into JOIN statement like this.

    SELECT a.emp_id,
           a.first_name
    FROM emp_master a 
            LEFT JOIN passport_details b
               on a.emp_id = b.emp_id
    WHERE a.`Status` = 1 AND
          b.emp_id IS NULL;
    
    0 讨论(0)
  • 2021-01-25 01:03
    select em.emp_id, em.first_name
    from emp_master em left join passport_details pd
        on pd.emp_id = em.emp_id and pd.status = 1
    where pd.emp_id is null
    

    I don't have a 3.23 instance to test with, but this should work.

    0 讨论(0)
  • 2021-01-25 01:06

    No, subqueries are not supported until 4.1: http://dev.mysql.com/doc/refman/4.1/en/mysql-nutshell.html

    0 讨论(0)
  • 2021-01-25 01:16

    A quick Google suggests that subqueries were brought in in MySql 4.1. So they're not supported in 3.23.

    Thy something along these lines instead:

    SELECT emp_id,first_name
    FROM emp_master
    JOIN passport_details ON emp_id
    WHERE status = 1;
    
    0 讨论(0)
提交回复
热议问题