A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
I need help to code this SQL statement
I do have a first table named PerformerProfiles. It has the two following columns: AutoNumber (This is a UNIQUEIDENTIFIER) and TUserName. For now these are the only two columns that concern us from this table. The second one is named DjOnlineShow. It has the following columns: SongAutoNumber(This is a UNIQUEIDENTIFIER), TArtistUserName, TArtistFirstName, TSongName, TMusicUrlAddress, TEntryDateTime and TWasPlayed. The only keys that link the two tables are TUserName and TArtistUserName. There isn’t any problem retrieving information linking both tables in a search when an artist is registered because of the keys. However when artists are not, there is not a UserName and therefore there is not key to link tables. But artist are allowed to list with ‘No register’ as TArtistUserName on the second table. So, if 50 artists are not register, but they all are willing to list their information, the TArtistUserName field would be the same for all of them (No register) on the second table. Now, I need the AutoNumber from the first table to display a picture of those registered artist. I know how to do it, but the problem is that when the process hit an artist that is not register, the code cannot access AutoNumber since there is no information for this artist on the first table. So, I need the SQl statement to reads like: If TArtistUserName is ‘No register’ assign a ramdon number or a constant (99999) to the AutoNumber just to fill the field. Since this number is fake, no picture is going to be display for the ‘No register’ artist anyway. So, how could I do this? This is my SQL statement in plain English and the one that I’m trying to code: Select all from PerformerProfiles and DjOnlineShow where TUserName = TArtistUserName and TWasPlayed = ‘No’ Order by TEntryDateTime Asc and all resulting records from this first query must display first or have preference over those that are not register from the next query. Now a subquery that select all the ‘No register’ Select all from DjOnlineShow where TArtistUserName = ‘No register’ and TWasPlayed = ‘No’ Order by TEntryDateTime Asc and for all resulting records add a field call AutoNumber with a constant 99999. This subquery result will be attached to the first query but all these records will be display last since records from registered artist have preference and display first. This order must be include as well, but I don’t know how to do it. Thanks to everybody for your help