By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,867 Members | 1,964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,867 IT Pros & Developers. It's quick & easy.

SQL Query question

P: 347
I have a page here

and a page here

and i want to include the artist Tilly from the kids page on the girls page but only when the age of Teenage is selected on the girls page.

the sql query for the girls page is

Expand|Select|Wrap|Line Numbers
  1. selectSQL = "SELECT * FROM celebs INNER JOIN celebsvoicetypes ON celebs.idnumber = celebsvoicetypes.celebidvoicetypes WHERE celebsvoicetypes.celebstypes ='" &voiceid& "' AND = 'girls' ORDER BY celebs.surname,celebs.firstname"
Tillys individual id number is 154.

i have tried

Expand|Select|Wrap|Line Numbers
  1. selectSQL = "SELECT * FROM celebs INNER JOIN celebsvoicetypes ON celebs.idnumber = celebsvoicetypes.celebidvoicetypes WHERE celebsvoicetypes.celebstypes ='" &voiceid& "' AND = 'girls' OR (idnumber like '154' AND celebsvoicetypes.celebstypes = 'Teenage') ORDER BY celebs.surname,celebs.firstname"
which can bee seen here

but tilly appears on the all page which i do not want

any ideas would be appreceated
Mar 21 '13 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 10K+
P: 12,370
What you should have is a table listing all the categories that a voice actor belongs to. Then you won't have to keep changing the SQL everytime you want to include someone else on another list.
Mar 21 '13 #2

P: 347
I do have a seperate table the lists which artists are in which section, the problem i have is that the main section for each artist is called All and that is used in the kids section aswell as the girls section so i can remove her from the All section otherwise all would be fine
Mar 22 '13 #3

P: 347
I now have this page

showing 3 of tilly when i go on it but at least she only shows up on the teenage section, cant figure out why though

sql is

Expand|Select|Wrap|Line Numbers
  1. selectSQL = "SELECT * FROM celebs INNER JOIN celebsvoicetypes ON celebs.idnumber = celebsvoicetypes.celebidvoicetypes WHERE celebsvoicetypes.celebstypes ='" &voiceid& "' AND = 'girls' OR (idnumber like '154' AND '" &voiceid& "' like 'Teenage') ORDER BY celebs.surname,celebs.firstname"
not much difference just changed an = to like
Mar 22 '13 #4

Expert Mod 10K+
P: 12,370
It would help to see the table layout and some sample data. If you're getting duplicates, that means you have Tilly in one of the tables more than once.
Mar 22 '13 #5

Post your reply

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