Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-9442

SELECT EXISTS returns false values when missing table information in where clause

    XMLWordPrintable

Details

    Description

      I found out, that SELECT Statements always return 0 when the table is empty, and 1 when there's data in the table. Independently of the used query. Let me citate my stack overflow solution.

      'Inside of a Stored Procedure Select Exists returns 1 when there is data in the table and null if there is no, when the query is written like that (without specific table set in the where clause): SELECT EXISTS (SELECT * INTO count FROM db.sequencial_host WHERE host_id = host_id_a ORDER BY insert_time DESC LIMIT 1);

      If you append the table to the host_id where clause it works as expected. Even counts return the expected value. SELECT EXISTS (SELECT * INTO count FROM db.sequencial_host WHERE sequencial_host.host_id = host_id_a ORDER BY insert_time DESC LIMIT 1);'

      http://stackoverflow.com/questions/34909887/mysql-stored-procedure-if-count-is-never-null/34911702#34911702

      Attachments

        Activity

          People

            Unassigned Unassigned
            joeysql joey doe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.