Link to home
Start Free TrialLog in
Avatar of Nemetona
Nemetona

asked on

MySQL Query only returns value based on 1st value in parameter string

MySQL 5.1.59
I am trying to select data in a query using another query for the parameter and the correct data is not being returned.

Select id from Table2 where id in(Select memberid from Table1 where id=43);

But when I run it only the very first value in Table2 is returned. i.e. 575

Can anyone tell me why this is happening and what I can do to change it?

CREATE TABLE `Table1` (
  `id` int(3) NOT NULL AUTO_INCREMENT,
  `memberID` varchar(300) CHARACTER SET latin1 DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1$$

ID      MEMBERID
24      563,568,566,565,561,466,567,572,571,100,564,560,573,562,569,570,
25      561,564,560,569,570,
31      561,560,569,570,
43      575,563,576,568,565,566,561,567,572,573,577,


CREATE TABLE `Table2` (
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `PROJECT ID` bigint(20) DEFAULT '0',
   PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=579 DEFAULT CHARSET=latin1$$

100      26
466      17
560      26
561      23
562      26
563      23
564      22
565      24
566      25
567      22
568      17
569      17
570      22
571      17
572      17
573      17
574      17
575      17
576      17
577      17
578      17
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nemetona
Nemetona

ASKER

Thank you so much, it exactly solves my problem.
Your welcome.