Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 simple sql query
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kacalapy
Starting Member

5 Posts

Posted - 23 December 2004 :  11:48:06  Show Profile
hi all,

got an easy oen here...

i got 2 tables in sql srvr2000. one contains galleries and the other projections.

i want to return all galleries that match a nile like '%gomez%' but only if the gallery_id is not 'trashed' in the projected table.

here is the curver ball. the projected table can have no records or multiple for any given gallery. if it has no record that is fine but if it has many i need to find the most recent and make sure its gallery_type is not "trashed".

the tables are linked by galelry_id

thank you all.

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 23 December 2004 :  12:02:35  Show Profile  Send pdrg a Yahoo! Message
Unless you've got some kinda datestamp or sequence ID you cannot do this - db records have no inherent 'order'.
I'm off home now - if you give more details (eg the schemas for the tables) I'll have a look tomorrow for ya (and that's service ;-) )
Go to Top of Page

kacalapy
Starting Member

5 Posts

Posted - 23 December 2004 :  13:39:14  Show Profile
wow,

yes there is a date field so you can prob get max() from it and an id field that should work the same in the projected table
Go to Top of Page

kacalapy
Starting Member

5 Posts

Posted - 23 December 2004 :  13:53:08  Show Profile
wow = goign home early

happy holidays all...
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 24 December 2004 :  07:08:18  Show Profile  Send pdrg a Yahoo! Message
lol@going home early - timezones, dear friend ;-)

Can a gallery be 'untrashed' again, or once 'trashed' does it die forever? This is the easiest case:

SELECT <some stuff> where gallery_ID not in (Select gallery_ID from projected where gallerytype = 'trashed') and gallery nile like '%gomez%'

(ie we exclude a list of galleryID's that are 'trashed' and return the rest - date is irrelevent if the 'trashed' state is as permenant as the name suggests!)

hope this helps - otherwise I'll have another look for you mid-jan - gotta dash :)

Merry Christmas :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.18 seconds. Powered By: Snitz Forums 2000 Version 3.4.07