Duplicate Return on rs

Duplicate Return on rs

am 16.03.2007 00:17:56 von Simon Gare

Hi all,

in my SQL select query I have a LEFT JOIN between 2 tables that returns a
value if the data from table 1 is present in table 2, below

dbo.booking_form.COLL_CONTACT_TEL = dbo.tblFlag.TelNoMo OR
dbo.booking_form.MOBILE_NO = dbo.tblFlag.TelNoMo

Problem is that if the COLL_CONTACT_TEL and MOBILE_NO are both present in
table 2 it returns the record twice in the asp page repeat region.

Can anyone help?

Regards

--
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk

Re: Duplicate Return on rs

am 16.03.2007 08:24:43 von Simon Gare

Just to expand

here's my problem, tried Select DISTINCT dbo.Flag.TelNoMo, etc, but error
read

"The text, ntext, or image data type cannot be selected as DISTINCT"

Full query is here


"SELECT dbo.booking_form.*, dbo.tblFlag.Flag, dbo.booking_form.ACCOUNT,
dbo.booking_form.TimeOfBooking, dbo.booking_form.VEHICLE_TYPE,
dbo.Customers.AccountNo, dbo.CarTypes.CarTypeID, dbo.CarTypes.ImageURL,
dbo.Customers.CompanyName FROM (((dbo.booking_form INNER JOIN dbo.CarTypes
ON dbo.booking_form.VEHICLE_TYPE = dbo.CarTypes.CarTypeID) ) INNER JOIN
dbo.Customers ON dbo.booking_form.ACCOUNT = dbo.Customers.AccountNo) LEFT
JOIN dbo.tblFlag ON (dbo.booking_form.COLL_CONTACT_TEL = dbo.tblFlag.TelNoMo
OR dbo.booking_form.MOBILE_NO = dbo.tblFlag.TelNoMo) WHERE allocated = '" +
Replace(BookingForm__MMColParam, "'", "''") + "' and timeofbooking >=
DateAdd(""hour"",-1, getdate()) ORDER BY TimeOfBooking ASC"

As you can see its complicated, would appreciate it if you have any
suggestions.

Regards
Simon

"Simon Gare" wrote in message
news:uUl%23hh1ZHHA.4872@TK2MSFTNGP03.phx.gbl...
> Hi all,
>
> in my SQL select query I have a LEFT JOIN between 2 tables that returns a
> value if the data from table 1 is present in table 2, below
>
> dbo.booking_form.COLL_CONTACT_TEL = dbo.tblFlag.TelNoMo OR
> dbo.booking_form.MOBILE_NO = dbo.tblFlag.TelNoMo
>
> Problem is that if the COLL_CONTACT_TEL and MOBILE_NO are both present in
> table 2 it returns the record twice in the asp page repeat region.
>
> Can anyone help?
>
> Regards
>
> --
> Simon Gare
> The Gare Group Limited
>
> website: www.thegaregroup.co.uk
> website: www.privatehiresolutions.co.uk
>
>