G
gjoneshtfc
Hello
I have a two menus where the user chooses the make and model of a car.
After submitting, a results page shows depending on their inputs. My
SQL is currently:
SELECT *
FROM MainTable
WHERE [model] = '" & chosenmodel & "'
ORDER BY Price DESC
I now want to introduce an option where they can search for any model
of a selected make, whilst still giving the option of searching by a
specific model. What i need is something like:
IF chosenmodel = "Any"
SELECT *
FROM MainTable
WHERE [make] = '" & chosenmake & "'
ORDER BY Price DESC
ELSE
SELECT *
FROM MainTable
WHERE [model] = '" & chosenmodel & "'
ORDER BY Price DESC
Unfortunately I have no idea how i can put this into SQL code as i am
new to the language. My searching for an answer so far has only lead to
me to using AND and OR as part of the WHERE command. However, this will
not work for what i want to do. Please can anyone help me?!
Thanks for your time,
Gareth
I have a two menus where the user chooses the make and model of a car.
After submitting, a results page shows depending on their inputs. My
SQL is currently:
SELECT *
FROM MainTable
WHERE [model] = '" & chosenmodel & "'
ORDER BY Price DESC
I now want to introduce an option where they can search for any model
of a selected make, whilst still giving the option of searching by a
specific model. What i need is something like:
IF chosenmodel = "Any"
SELECT *
FROM MainTable
WHERE [make] = '" & chosenmake & "'
ORDER BY Price DESC
ELSE
SELECT *
FROM MainTable
WHERE [model] = '" & chosenmodel & "'
ORDER BY Price DESC
Unfortunately I have no idea how i can put this into SQL code as i am
new to the language. My searching for an answer so far has only lead to
me to using AND and OR as part of the WHERE command. However, this will
not work for what i want to do. Please can anyone help me?!
Thanks for your time,
Gareth