Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kattlees
Starting Member
3 Posts |
Posted - 2014-04-23 : 11:39:46
|
I am fairly new to SQl and PHP and have a question. I have a database that we enter in when a person buys a season ticket for our baseball team. I want to check and see who bought in 2013 but has not yet bought in 2014. How do I do that?THID is the ticket holder ID and there is a year. I can do the select * from Passes where Year = '2014' and get everyone who has bought in 2014. How do I compare that with the 2013 and show people who have not bought yet in 2014?Example entry:THID PassType Year15 2 201321 1 201310 1 201321 1 2014With this - Ticket holder 21 has bought in both years so I wouldn't want his name to come up. I would want to see that ticket holders 15 and 10 haven't yet bought in 2014. |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-04-23 : 13:03:54
|
>>I am fairly new to SQl and PHPThis forum is specific to MS Sql Server.However, for sql server this would work:select thid, passtype,year from myTable where year = 2013 and thid not in (select thid from myTable where year = 2014)Be One with the OptimizerTG |
|
|
|
|
|