PHP/MySQL Query Assistance

Hi all,

I’m looking for some assistance with the below:-

I currently have Table A and Table B; within Table A I have a collumn that contains “35 65 79”, for example, the numbers contained therein are each unique rows on Table B. I’m needing to create a method of querying Table B for each of the aforementioned, the quantity of the numbers contained in Table A’s columns can vary so using string[0] string[1] etc is not reliable, I’ve also explored the use of explode and have had little succes.

Please see the below code I’m currently working with:-

[php] $TableAQuery = mysql_query(“SELECT * FROM TableID WHERE Column = ‘1’”) or die(mysql_error());
while ($TableAResult = mysql_fetch_array($TableAQuery)) {

	foreach ($TableAResult["UniqueID"] as $value) {
		$TableBQuery = mysql_query("SELECT * FROM `TableB` WHERE UniqueID = '".$value."'") or die(mysql_error());  
		$TableBResult = mysql_fetch_array($TableBQuery);
		echo $TableBResult["Name"];
	}

[/php]

Thanks in advance !

That is a horrible design. A single column record should not exceed a single value. That means, no delimited fields, nothing extra other than the single specific value that the column represents.

Next, quit using mysql_ functions! They are removed from the latest version and were insecure for database interactions 10 years ago.

Sponsor our Newsletter | Privacy Policy | Terms of Service