Buchead Posted December 27, 2006 Share Posted December 27, 2006 Hello...This is more of a question to find out if a query is possible.In one table I have columns for ID (unique, incremental) and name. In another table I have another column for ID (unique, incremental) and one the called info. This contains various IDs from the first table in the format of ;1;20;23; etc.....What I'm attempting to do is pull the names from the first table where that ID is in the info column of the 2nd table, depending upon the ID of the 2nd table specified.I have the query:[code]SELECT a.name FROM `table1` AS a INNER JOIN `table2` AS b ON a.ID=b.info WHERE b.ID='$ID'[/code]The problem I'm experiencing is how to specify a LIKE in the a.ID-b.info part. If I wanted to simply select date from table2 I could use WHERE b.info LIKE '%$value%', but can't get wildcards to work around b.info (if that's possible at all).I can't really specify where any in table2 is like table1 ID as if searching on an ID of 1 it would give any result containing 1.Is what I want to achieve possible?Thanks. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 27, 2006 Share Posted December 27, 2006 You're going to run into many other problems if you're storing lists of IDs like that... Quote Link to comment Share on other sites More sharing options...
Buchead Posted December 28, 2006 Author Share Posted December 28, 2006 Cool. Thanks for that but 2 questions:1) any idea what problems I could run into, and2) what's a better way to store the IDs?I could have an undetermined number of IDs to store, and rather than create a large number of columns, of which many would remain empty, I thought it best to be stored in one column. Or is it the ';' that will cause the problems?Thanks. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 30, 2006 Share Posted December 30, 2006 What you need is another table that relates pairs of table records; that way, you can easily link the two, no extra columns in either table. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.