0

I am trying to return a distinct list of hotel_country, hotel_resort and hotel_title and CHARACTER_LENGTH of each of these in the column next to it. I am doing something wrong as I am getting the error

Commands out of sync; you can't run this command now 

This error is something I have not seen before and do not understand it. If I take the FROM and the WHERE out of the sub query data is returned, although I am not sure if this data is correct as it is not restricted.

In MySQL can you not use a FROM and WHERE in a subquery?

My MySQL is below - thanks in advance for help.

SELECT DISTINCT hotel_country, CHARACTER_LENGTH(hotel_country) as   hotel_country_length,

(SELECT DISTINCT hotel_resort
FROM client_x
WHERE item_status = 1) as hotel_resort,

(SELECT  CHARACTER_LENGTH(hotel_resort)
FROM client_x
WHERE item_status = 1
) as hotel_resort_length,

CHARACTER_LENGTH(hotel_country) + CHARACTER_LENGTH(hotel_resort) +
CHARACTER_LENGTH(hotel_title) as total_length

FROM client_x
WHERE item_status = 1

Thanks for marking this a duplicate although it is not.

I believe this is an issue with phpMyAdmin as when I run this through a terminal i get a different response

MrsPop88
  • 303
  • 4
  • 14

0 Answers0