?
Solved

SELECT with an array condition.

Posted on 2005-03-02
9
Medium Priority
?
243 Views
Last Modified: 2009-07-29
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
Comment
Question by:drcyrus3d
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13438723
mysql_query("select * from table_name where Zone<>'".$row_Comune['id']."'");

??
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 13438754
I've allready tried this but it wont show any records.
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 13438784
The data contained in the zone column is from an array.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 32

Expert Comment

by:Batalf
ID: 13438936
What's the format of the zone column? What is a typical value of that column.

"1,2,3,4" or??
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 13439108
"1","2","3","4"; but i can reformat it if it's needed.
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 13439116
it's a text field.
0
 
LVL 32

Accepted Solution

by:
Batalf earned 1400 total points
ID: 13439136
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
 
LVL 1

Author Comment

by:drcyrus3d
ID: 13439205
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
 
LVL 32

Expert Comment

by:Batalf
ID: 13439239
Glad I could help!

Thanks for the "A" grade

Batalf
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question