Jump to content


Photo

help please


  • Please log in to reply
3 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 25 August 2006 - 11:52 AM

$sql = "select * from table1 where members_id not in (select selected_id from table2 where 1)";

is this correct as i cant get it to work

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 25 August 2006 - 12:08 PM

select selected_id from table2 where 1


That isn't a valid sql query.  Aside from your subselect being jacked, it should work.

SELECT * FROM table1 WHERE members_id NOT IN (SELECT selected_id FROM table2);


#3 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 25 August 2006 - 12:12 PM

SQL-query : 

SELECT *
FROM websites
WHERE websites_id NOT
IN (


SELECT websites_hits_id
FROM websites_hits
)
LIMIT 0 , 30

MySQL said:


#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 websites_hits_id
FROM websites_hits ) LIMIT 0, 30' at li

#4 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 25 August 2006 - 01:53 PM

sub selects were only added in mysql 5, check which version of mysql you have.

Also,
SELECT * FROM `table` WHERE 1
is a valid query, try it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users