Select + Comma Seperated Field

I am wondering if there is a way where i can have a select statement where in there WHERE clause it searches a Comma Seperated Field
i have not had any luck with this as of yet, and and not sure how to go about getting the result i need

here is some information to help you help me

table employee

| ID || emp_firstname || emp_position || emp_store ||
1 Dilbert CSR 1002
2 Frank D Manager 1001,1002,1003
3 Bettie Manager 1002

etc…

$store = 1001 ;
 
  $result = mysql_query("SELECT emp_firstname, emp_position FROM employee WHERE emp_store= ".$store) or die(mysql_error());	
	while($row = mysql_fetch_array($result)) {
	
	echo "Name: ". $row[emp_firstname]. " Position: ". $row[emp_position]."<br >";
	}

thanks in advance

Look up ‘normalize database’ on Google. Comma-separated fields in an RDBMS are usually bad-practise and it’s better to just use a 1xN relation table:

[code]Table ‘employee’:
ID emp_firstname emp_position
1 Dilbert CSR
2 Frank D Manager
3 Bettie Manager

Table ‘employee_store’:
ID emp_store
1 1002
2 1001
2 1002
2 1003
3 1002[/code]

Sponsor our Newsletter | Privacy Policy | Terms of Service