********************************************************* I've sent two other related emails (11:30 and 11:36) but the date on my machine was set to 18/04/2002. I've changed this now. The reason was because I'm developing with evaluation software that timed out in May :-) *********************************************************
Here's a description of the table relationships... To use the system you have to be in the [Users] table. Each user is part of a [Groups] and they're linked together using the intermediate [Users_Groups_Link] table - many to many. A given [Users] can be the administrator of a [Groups] and this is indicated by the [Groups]Administrator field having the value from [Users]Forename. [Adverts] stores info about Adverts and they have 'many' [Advert_Fields] related to them. There is an [Advert_Fields]Data field (which is what I want to include in my SQL Query Statement). Below is my current SQL statement with an added variable... DECLARE @userid AS int SET @userid = 3 DECLARE @data AS nvarchar(30) SET @data = 'car' SELECT DISTINCT Adverts.Identifier FROM Adverts WHERE Adverts.FK_Users = @userid UNION SELECT DISTINCT Adverts.Identifier FROM Groups INNER JOIN Users_Groups_Link ON Users_Groups_Link.FK_Groups = Groups.PK_ID INNER JOIN Adverts ON Adverts.FK_Users = Users_Groups_Link.FK_Users WHERE Groups.Administrator = (SELECT Users.Forename FROM Users WHERE Users.uID = @userid) I'm pretty sure how to modify the first SELECT in the UNION to include the extra the table and field... SELECT DISTINCT Adverts.Identifier FROM Advert_Fields INNER JOIN Adverts ON Adverts.PK_ID = Advert_Fields.FK_Adverts AND Adverts.FK_Users = @userid WHERE Advert_Fields.Data LIKE '%' + @data + '%' ... but how would I modify the second SELECT in the UNION to include the "Advert_Fields.Data LIKE '%' + @data + '%'" statement? Thanks everyone! Nick --- You are currently subscribed to activeserverpages as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
