Loading

customers with tags

  1. SELECT tbl1.*,
  2. (SELECT GROUP_CONCAT(access_name SEPARATOR ',')
  3. FROM access_staff af, access a
  4. WHERE af.staff_id = 236
  5. AND a.access_id = af.access_id) tags
  6. FROM (
  7. SELECT DISTINCT trading_name.id_trading_name AS trading_id, trading_name.trading_name, trading_name.address1, trading_name.postcode, trading_name.tel, trading_name.email
  8. FROM trading_name
  9. INNER JOIN access_trading ON access_trading.trading_id = trading_name.id_trading_name INNER JOIN access_staff ON access_staff.access_id = access_trading.access_id INNER JOIN access ON access_trading.access_id = access.id
  10. WHERE (trading_name.deleted = 0) AND (access_staff.staff_id = 236) AND (trading_name.trading_name LIKE '%wright%')
  11. ORDER BY trading_name.trading_name
  12. ) tbl1;

Comments