How do I select a data from other likely data
Posted: Tue Sep 02, 2014 4:39 pm
Hello friends,
I have a range of numbers in a table like below,
CATEGORIES TABLE
ID CATEGORY
1 Accounting
2 Real Estate
3 Banking & Finance
4 Aviation
5 Biochemistry
6 Poultry
etc
MEMBERS TABLE
ID CATEGORIES
1 2, 5, 7, 13, 21
2 3, 4, 5, 6, 10, 15
3 3, 7, 9
4 1, 15, 32, 35
5 8, 9, 12,
To view members under a category, the category id is passed as a string ($category) to the Category Page
Now i need to select Members that can work under Banking & Finance (3) so i used this query
It is expected that the result should be ID 2 & ID 3, but it will also bring members with ID 1 (because it has 13) & ID 4 (that has 35).
Pls How do I select members with 3 and not 13 or 33 or 23 or 30 etc
Thanks,
I have a range of numbers in a table like below,
CATEGORIES TABLE
ID CATEGORY
1 Accounting
2 Real Estate
3 Banking & Finance
4 Aviation
5 Biochemistry
6 Poultry
etc
MEMBERS TABLE
ID CATEGORIES
1 2, 5, 7, 13, 21
2 3, 4, 5, 6, 10, 15
3 3, 7, 9
4 1, 15, 32, 35
5 8, 9, 12,
To view members under a category, the category id is passed as a string ($category) to the Category Page
Now i need to select Members that can work under Banking & Finance (3) so i used this query
Code: Select all
$category = 3;
$get = mysql_query("SELECT id FROM members WHERE categories='%$category%'");
Pls How do I select members with 3 and not 13 or 33 or 23 or 30 etc
Thanks,