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.
LVL 1
drcyrus3dAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.