Oracle sql return true if exists question

后端 未结 5 1267
清酒与你
清酒与你 2021-01-03 21:12

How do I check if a particular element exists in a table - how can I return true or false?

I have a table that has

  • user_id
  • user_password
5条回答
  •  时光说笑
    2021-01-03 21:53

    There is no Boolean type in Oracle SQL. You will need to return a 1 or 0, or some such and act accordingly:

    SELECT CASE WHEN MAX(user_id) IS NULL THEN 'NO' ELSE 'YES' END User_exists
      FROM user_id_table
     WHERE user_id = 'some_user';
    

提交回复
热议问题