Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    8

    Red face Unanswered: Problem with SQL Query using EXISTS

    Hi, I have a problem with an sql that uses EXISTS, and NOT EXISTS, but it throws me the error:
    Syntaxis error or access violation
    the query is:
    SELECT *
    FROM GRVALACD.TCRECLI
    WHERE EXISTS
    (SELECT *
    FROM GRVALACD.TCREDSAL);
    does anyone knows which is my error?
    Thanks.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Unless you are running the experimental 4.1 release of MySQL, sub-queries aren't supported, so neither is the EXISTS predicate.

    You can approximate its behavior using JOIN operations, something like:
    PHP Code:
    SELECT a.*
       
    FROM GRVALACD.TCRECLI AS a
       JOIN GRVALACD
    .TCREDSAL AS b
          ON 
    (b.fk a.pk)
       
    WHERE  b.column 'fubar'
    Where you join a to b on a key value and you specify whatever other constraints you need in the WHERE clause.

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •