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 |
|
vivek328
Starting Member
1 Post |
Posted - 2008-11-24 : 10:33:04
|
| I have a database named emedia. in there there are two tables invoices and objectlist. table invoices has two columns date and recid, and table objectlist has two columns recid and objectid. i need to query data on recid for date '2008' (under the table invoices)then take all those recids recieved and query objectid (under the table objectlist)how can i get this done? thanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-24 : 10:36:51
|
| [code]select i.recid,o.objectidfrom objctlist ojoin invoices ion i.recid=o.recidwhere date >= '20080101'and date < '20090101'[/code] |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-11-24 : 10:49:48
|
| Another solution some what similar to aboveselect i.recid,o.objectidfrom objctlist ojoin invoices ion i.recid=o.recidwhere year(i.date) = 2008 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-24 : 10:53:38
|
quote: Originally posted by raky Another solution some what similar to aboveselect i.recid,o.objectidfrom objctlist ojoin invoices ion i.recid=o.recidwhere year(i.date) = 2008
this wont use index if you've one present in date field |
 |
|
|
|
|
|