我正在执行以下有一些语法错误的查询:
SELECT count (tbl_staff.staff_id as staff_number),SELECT count (tbl_client.client_id as client_number),SELECT count (tbl_appointment.appt_id as appt_number),SELECT count (tbl_subscription.subscription_id as subscription_number)
FROM tbl_subscription
LEFT JOIN tbl_staff
ON (
tbl_staff.merchant_id = tbl_subscription.merchant_id)
LEFT JOIN tbl_appointment
ON (
tbl_appointment.merchant_id = tbl_subscription.merchant_id)
LEFT JOIN tbl_client
ON (
tbl_client.merchant_id = tbl_subscription.merchant_id)
WHERE tbl_subscription.subscription_id=1;
我想在特定的Subscription_id上获取staff_id,client_d,appointment_id的计数。
答案 0 :(得分:1)
您的选择列表已关闭,但有一些错误。也就是说,在查询中只需要一个SELECT(每个字段不需要一个),而“as ...”描述符属于括号外。
所以这部分查询
SELECT count (tbl_staff.staff_id as staff_number),
SELECT count (tbl_client.client_id as client_number),
SELECT count (tbl_appointment.appt_id as appt_number),
SELECT count (tbl_subscription.subscription_id as subscription_number)
FROM tbl_subscription
会变成
SELECT count (tbl_staff.staff_id) as staff_number,
count (tbl_client.client_id) as client_number,
count (tbl_appointment.appt_id) as appt_number,
count (tbl_subscription.subscription_id) as subscription_number
FROM tbl_subscription