473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Select based on one field being different values

nathj
938 Expert 512MB
Hi,

I have developed a table for storing navigation items, this is then used to built the navigation panel on my website.

Each item has a field indicating which bar it is to go on:
0 = Every bar,
1 = Top level page only
2 = Child page 1 only
3 = Child Page 2 only
99 = All child pages

So If iwas building up the navigation panel for child page 2 I need to get all items where the bar is set as 0 or 3 or 99.

I have experience writing software in Visual FoxPro which had a built in function called inlist(field, value1, value2, ...). I know this was built in function and it basically worked as
id = 0 or id = 3 or id = 99.

My question is this. Is there something similar in mySQL or do I simply need to build the list with the'or' in it?

Many thanks
nathj
Jul 10 '07 #1
3 1454
r035198x
13,262 8TB
Hi,

I have developed a table for storing navigation items, this is then used to built the navigation panel on my website.

Each item has a field indicating which bar it is to go on:
0 = Every bar,
1 = Top level page only
2 = Child page 1 only
3 = Child Page 2 only
99 = All child pages

So If iwas building up the navigation panel for child page 2 I need to get all items where the bar is set as 0 or 3 or 99.

I have experience writing software in Visual FoxPro which had a built in function called inlist(field, value1, value2, ...). I know this was built in function and it basically worked as
id = 0 or id = 3 or id = 99.

My question is this. Is there something similar in mySQL or do I simply need to build the list with the'or' in it?

Many thanks
nathj
In does that nicely
Expand|Select|Wrap|Line Numbers
  1. select ... where field in (0, 3, 99);
Jul 10 '07 #2
nathj
938 Expert 512MB
In does that nicely
Expand|Select|Wrap|Line Numbers
  1. select ... where field in (0, 3, 99);
Perfect. That's exactly what I wanted. I have only ever used in for subqueries before and so it didn't even cross my mind.

Thank you for your help, it not only performs better it makes my query easier to build!

Cheers
nathj
Jul 10 '07 #3
r035198x
13,262 8TB
Perfect. That's exactly what I wanted. I have only ever used in for subqueries before and so it didn't even cross my mind.

Thank you for your help, it not only performs better it makes my query easier to build!

Cheers
nathj
* blush *
Jul 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Neal | last post by:
I can have a visitor choose a subject line for an email. <div><label for="subject">Subject:</label><br /> <select class="form" id="subject" name="subject"> <option value="one">One</option>...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
1
by: Jason Wood | last post by:
Hi everyone, I've a simple table containing member details. I've written a SELECT to select all the members. I've based the form on this select, using the from wizard. Once built I've...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
3
by: stefaan.lhermitte | last post by:
Dear MySQL-ians, I perform a SELECT on my database, but it takes over a minute for every run. I have to run it over 10000 times (with different values in the WHERE), so it takes way too long. A...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
1
by: Wayne Deleer | last post by:
Here's a perplexing thought... right now I'm writing an application that uses a web form, with many different input types. Some of these types are lists that allow for multiple selections. After...
2
by: Genalube | last post by:
I am running a query that includes the inclusion of memo fields, my query pulls from four different tables with one to many relationships between them. The relationships are such that when I run my...
1
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just...
22
by: Rickster66 | last post by:
As Instructed this is a new thread regarding my original post: "Select Only 10 Columns Going Back" I'm sorry for the late response. I've been gathering up information and carefully with as much...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.