473,398 Members | 2,212 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,398 software developers and data experts.

select with multiple AND and OR attributes

I am trying to do something fairly simple.

I have two pages. Brands.php and Products.php.

When I click on Brands.php it takes me to a list of Brands. I click on a brand, for example, brand1.php. From there I can choose a category - Category1.

Category1 needs to go to store.php?BrandID=1&CatID=1. At this point I have only got it to filter by either or... either BrandID or CatID. So I go to store.php?BrandID=1, I get all items that are under Brand1, and similarly, when I go to CatID=1, I get all items that are under category1.

The problem is that I cannot get it to filter by BrandID and CatID together. I need something of a combination of the AND/OR fuction in SQL.

At this point here is what I have:

SELECT *
FROM products
WHERE BrandID = colname OR CatID = colname2

I have two variables defined: colname and colname2.

Name: colname
Type: Numeric
Default value: -1
Run-time Value: $_GET['BrandID']

Name: colname2
Type: Numeric
Default value: -1
Run-time Value: $_GET['CatID']


This is successfully doing what I have described above, but I need it to filter by each one individually AND both together.

I have tried:

SELECT *
FROM products
WHERE (BrandID = colname OR CatID = colname2) OR (BrandID= colname AND CatID = colname2)

but it did not succeed. Do I need to add a new colname3, perhaps?

I am using Dreamweaver's Advanced Recordset.

Your help and detailed answer will be greatly appreciated!

Thanks!
Jan 6 '08 #1
1 1553
ronverdonk
4,258 Expert 4TB
I would like to know what is the reasoning behind such a select. Because I cannot see any meaning in this.

this second part of the where clause is completely unnecessary;
Expand|Select|Wrap|Line Numbers
  1. BrandID= colname AND CatID = colname2)
because the result is already determined by the first part of the WHERE clause.

Maybe I don't understand it. In that case would you please explain why you would want and how you would use thee results of such a select.

Ronald
Mar 10 '08 #2

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

Similar topics

1
by: Chris | last post by:
Hi, I just would like to iterate through some attributes of a tag (Section). Sometimes I only need one attribute and sometimes I need all attributes. In a xsl:param I declare the attribute name...
19
by: Steve Jorgensen | last post by:
I've run across this issue several times of late, and I've never come up with a satisfactory answer to the best way to handle this schema issue. You have a large section of schema in which a...
1
by: Mad Scientist Jr | last post by:
I'm stuck trying to work with a HTML <SELECT> control and javascript (similar to DualList but that control doesn't offer enough options to totally control the text on the buttons and control, also...
2
by: George Durzi | last post by:
This is more of a design/philosophical question :) I have a page in which the user sets attributes for a project. There are 8 attributes, e.g. Project Type, Country, etc. The number of options...
4
by: sakieboy | last post by:
I currently have a datagrid with several columns. The first column in the DataGrid is a HyperLinkColumn. When I select a row, I would like for this HyperlinkColumn to fire. I have the mouseover...
1
by: darrel | last post by:
On some of my pages I add a javascript call dynamically to the BODY tag: pageBody.Attributes.add("onload", "dothis();") Since this adds an actual attribute, trying to call this multiple times...
1
by: puneet.bansal | last post by:
Hi, I want to know the index of the option that a user clicks on in a multiple-select object (regardless of whether he selected or deselected it). This seems fairly simple but I can't seem to...
2
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID)...
7
by: prash.marne | last post by:
Hello, I have a simple form <form method="POST"> <select name="activity"> <option value="0">None</option> <option value="M" onclick="popup_onclick()">Select Multiple</option> <option...
0
by: djflow | last post by:
Hi! II was wondering if you can help me with SQL query.. Below 7 separated select query works fine(only when they are retrieved separately) But I want to combined them together and so that i...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.