-1

大家好,我有问题。

我有两个返回不同结果的 SQL 查询:

SELECT name, capacity, $price, licensed, cost 
FROM venue, catering WHERE venue.venue_id = catering.venue_id 
AND grade=$grade 
AND capacity >= $minCapacity
AND capacity <= $maxCapacity
AND venue.venue_id 
NOT IN (SELECT venue_id FROM venue_booking WHERE date_booked = $us_date)

SELECT venue.venue_id,name,capacity,licensed,$price,cost
FROM venue
JOIN catering ON venue.venue_id = catering.venue_id
WHERE capacity BETWEEN '$minCapacity' AND '$maxCapacity' 
AND venue.venue_id NOT IN 
(SELECT venue_id
FROM venue_booking
WHERE date_booked = '$us_date')
AND catering.grade = '$grade' ORDER BY venue.capacity

这里有什么区别?

4

1 回答 1

5

我的感觉..主要区别是-

在第一个查询中,您正在使用条件检查容量 -

AND capacity >= $minCapacity
AND capacity <= $maxCapacity

这将作为数字 ..

但在第二个查询中,此条件在两个字符串值的范围内..

于 2012-05-23T14:15:19.200 回答