LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2006, 06:33 PM   #1
firemankurt
LQ Newbie
 
Registered: Jul 2006
Location: Ferndale WA USA
Distribution: MEPIS 6
Posts: 20

Rep: Reputation: 0
MySQL delete with subquery


OK... This is driving me crazy. I know I can do two seperate queries to accoomplish this but I should not have to.

I am trying to check the `MPAConfig` file to see if a record exists.
(If that record exists then the current user has admin rights in the program.)
If that record exists then go ahead and delete some records in a different table.


Code:
DELETE 
FROM  
      `MPApagers`  
WHERE
      1 = ( SELECT 1
            FROM 
                `MPAConfig`
            WHERE
                `Setting` = 'ProfileAdmins'
            AND
                `Par4` LIKE BINARY '%Z%' )
AND 
     `EMPNUM` = '9902'
MySQL responds:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1
FROM
`MPAConfig`
WHERE
`Setting`
 
Old 09-30-2006, 04:43 AM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
This probably won't be of much help, but I just tried to imitate your query and it works fine. The statement I used was
Code:
select * from indices where 1=(select 1 from shares where ISIN="DE0006231004");
I'm using MySQL 5.0.
 
Old 09-30-2006, 06:02 AM   #3
jon23d
Member
 
Registered: May 2006
Location: Kennewick, WA - USA
Distribution: Ubuntu
Posts: 129

Rep: Reputation: 15
I believe that only version 4.1 and later supports subselects.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL: Help with using join to simulate subquery MicahCarrick Programming 1 09-30-2006 07:17 AM
Subquery mysql dont work cuencano General 1 08-03-2005 12:30 AM
How to delete a column in MySQL ? indian Linux - General 2 10-15-2004 01:02 PM
MySQL: Subquery in HAVING clause ugenn Programming 2 08-11-2002 11:49 AM
PHP/mysql delete problem crabboy Programming 1 08-10-2001 09:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration