Php 如果您的标题字段可以为空,那么使用book.isbn13也会更安全。我刚才也尝试过,因为有些标题是空的。在我看来是个赢家。我确实需要在I.isbn13=book.isbn13上添加一个左连接书,仅供参考。再次感谢您的帮助。很抱歉在测试您的示例时出现延迟,但
Php 如果您的标题字段可以为空,那么使用book.isbn13也会更安全。我刚才也尝试过,因为有些标题是空的。在我看来是个赢家。我确实需要在I.isbn13=book.isbn13上添加一个左连接书,仅供参考。再次感谢您的帮助。很抱歉在测试您的示例时出现延迟,但,php,mysql,aggregate,Php,Mysql,Aggregate,如果您的标题字段可以为空,那么使用book.isbn13也会更安全。我刚才也尝试过,因为有些标题是空的。在我看来是个赢家。我确实需要在I.isbn13=book.isbn13上添加一个左连接书,仅供参考。再次感谢您的帮助。很抱歉在测试您的示例时出现延迟,但是当我运行它时,我在上看到一个sql语法错误,即“cnt”。我不确定这本书是什么。意思是说,你能解释一下吗?这样我就可以更正错误并重试代码了?。Thanksbook是book表,我仍然想知道为什么会出现语法错误,stll检查…我做了一些更改,并
如果您的标题字段可以为空,那么使用book.isbn13也会更安全。我刚才也尝试过,因为有些标题是空的。在我看来是个赢家。我确实需要在I.isbn13=book.isbn13上添加一个左连接书,仅供参考。再次感谢您的帮助。很抱歉在测试您的示例时出现延迟,但是当我运行它时,我在上看到一个sql语法错误,即“cnt”。我不确定这本书是什么。意思是说,你能解释一下吗?这样我就可以更正错误并重试代码了?。Thanksbook是book表,我仍然想知道为什么会出现语法错误,stll检查…我做了一些更改,并将book.*更改为book.title,它似乎可以工作。我仍然需要验证数学,但乍一看似乎很接近。谢谢你的帮助。好的,很酷,我只是想弄明白,如果你的标题字段可以为空,那么使用book.isbn13也会更安全。我刚才也试过了,因为有些标题是空的。在我看来是个赢家。我确实需要在I.isbn13=book.isbn13上添加一个左连接书,仅供参考。再次感谢你的帮助。
SELECT sku, quantity, inventory.isbn13, author, title, pub_date, binding,
defect.defect, source, location from inventory
LEFT JOIN location ON inventory.location_id = location.location_id
LEFT JOIN source ON inventory.source_id = source.source_id
LEFT JOIN book ON inventory.isbn13 = book.isbn13
LEFT JOIN defect ON inventory.defect_id = defect.defect_id
LEFT JOIN book_condition ON book_condition.condition_id = defect.condition_id
WHERE quantity > '0' and location.location_id >= '986' and location.location_id <= '989'
ORDER BY inventory.location_id, sku
foreach ($results as $row) {
$location_count [$row['location_id']]++;
}
echo $location_count [986]; // outputs 17
SELECT count(*), sku, quantity, inventory.isbn13, author, title, pub_date, binding,
defect.defect, source, location from inventory
LEFT JOIN location ON inventory.location_id = location.location_id
LEFT JOIN source ON inventory.source_id = source.source_id
LEFT JOIN book ON inventory.isbn13 = book.isbn13
LEFT JOIN defect ON inventory.defect_id = defect.defect_id
LEFT JOIN book_condition ON book_condition.condition_id = defect.condition_id
WHERE quantity > '0' and location.location_id >= '986' and location.location_id <= '989'
ORDER BY inventory.location_id, sku
GROUP BY location.location_id
mysql> select * from actor where actor_id>190;
+----------+------------+-------------+---------------------+
| actor_id | first_name | last_name | last_update |
+----------+------------+-------------+---------------------+
| 191 | GREGORY | GOODING | 2012-05-22 15:12:26 |
| 192 | JOHN | SUVARI | 2012-05-22 15:12:26 |
| 193 | BURT | TEMPLE | 2012-05-22 15:12:26 |
| 194 | MERYL | ALLEN | 2012-05-22 15:12:26 |
| 195 | JAYNE | SILVERSTONE | 2012-05-22 15:12:26 |
| 196 | BELA | WALKEN | 2012-05-22 15:12:26 |
| 197 | REESE | WEST | 2012-05-22 15:12:26 |
| 198 | MARY | KEITEL | 2012-05-22 15:12:26 |
| 199 | JULIA | FAWCETT | 2012-05-22 15:12:26 |
| 200 | THORA | TEMPLE | 2012-05-22 15:12:26 |
| 205 | 1 | 2 | 0000-00-00 00:00:00 |
| 206 | a | b | 0000-00-00 00:00:00 |
+----------+------------+-------------+---------------------+
12 rows in set (0.00 sec)
mysql> select FOUND_ROWS();
+--------------+
| FOUND_ROWS() |
+--------------+
| 12 |
+--------------+
1 row in set (0.00 sec)
SELECT
sku,
quantity,
inventory.isbn13,
author,
title,
pub_date,
binding,
defect.defect,
source,
location,
t.cnt
FROM
inventory i
INNER JOIN
(
SELECT
inventory.location_id,
COUNT(book.isbn13) as `cnt`
FROM inventory
LEFT JOIN book ON inventory.isbn13 = book.isbn13
GROUP BY inventory.location_id
) t ON t.location_id = i.location_id
INNER JOIN location l ON i.location_id = l.location_id
LEFT JOIN source ON i.source_id = source.source_id
LEFT JOIN defect ON i.defect_id = defect.defect_id
LEFT JOIN book_condition ON book_condition.condition_id = defect.condition_id
WHERE
i.quantity > '0'
AND l.location_id >= '986'
AND l.location_id <= '989'