Johny Bravo
asked on
Help with SQL Query (Join)
Hi Experts,
I have two tables
1> Amenity
AmenityId (Int,PK)
Amenity (varchar(200)
2> HotelDetails
HotelId (int,PK)
HotelName (varchar(250)
AmenityId (varchar(200))
As you can see in hotelDetails amenity Ids are stored as CSV.
Like
2,4,7,8
Now I want to display Amenities of Hotels.
How to join these tables?
I have two tables
1> Amenity
AmenityId (Int,PK)
Amenity (varchar(200)
2> HotelDetails
HotelId (int,PK)
HotelName (varchar(250)
AmenityId (varchar(200))
As you can see in hotelDetails amenity Ids are stored as CSV.
Like
2,4,7,8
Now I want to display Amenities of Hotels.
How to join these tables?
ASKER
Hi Expert,
Thanks for the reply
>>Ideally the Hotel Details table should have one row per amenity for an easy table join
Agreed but can't change the table definition.
The query given by you is not working in SQL server
Thanks for the reply
>>Ideally the Hotel Details table should have one row per amenity for an easy table join
Agreed but can't change the table definition.
The query given by you is not working in SQL server
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you can try something like this. Please excuse my concatantion syntax if I have it wrong for SQL Server
Open in new window