Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

SELECT with an array condition.

I have a column in my database called Zone. It contains data from an array previously entered; ex: "1","2","3","4";

I want to make a SELECT from the database and show all the records, where the Zone column does not contain $row_Comune['id'].

Thanks.
0
drcyrus3d
Asked:
drcyrus3d
  • 5
  • 4
1 Solution
 
BatalfCommented:
mysql_query("select * from table_name where Zone<>'".$row_Comune['id']."'");

??
0
 
drcyrus3dAuthor Commented:
I've allready tried this but it wont show any records.
0
 
drcyrus3dAuthor Commented:
The data contained in the zone column is from an array.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
BatalfCommented:
What's the format of the zone column? What is a typical value of that column.

"1,2,3,4" or??
0
 
drcyrus3dAuthor Commented:
"1","2","3","4"; but i can reformat it if it's needed.
0
 
drcyrus3dAuthor Commented:
it's a text field.
0
 
BatalfCommented:
Ok, try

mysql_query("select * from table_name where Zone NOT LIKE '%\"".$row_Comune['id']."\"%'");

It could be a good idea to rethink your database design. Maybe one zone per row!?

Batalf
0
 
drcyrus3dAuthor Commented:
as you said before:

mysql_query("select * from table_name where Zone NOT LIKE '%\"".$row_Comune['id']."\"%'");
It shoes me only the records that are in the array.

I skiped the "NOT" and it works perfectly.
mysql_query("select * from table_name where Zone LIKE '%\"".$row_Comune['id']."\"%'");

Thanks a lot.
0
 
BatalfCommented:
Glad I could help!

Thanks for the "A" grade

Batalf
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now