Kesalahan Query MySQL Bila Tipe kolom varchar vs integer
Query Varchar
SELECT * FROM `purchase_order` WHERE status = 0 # output +----+------------+------------+---------+---------+-------------------+------------+------------+--------+---------------------+---------------------+ | id | po_number | po_date | site_id | status | file_pdf | updated_by | created_by | active | created_at | updated_at | +----+------------+------------+---------+---------+-------------------+------------+------------+--------+---------------------+---------------------+ | 1 | 8100009248 | 2016-05-31 | 1 | Dikirim | 81-9248.pdf | 2 | 2 | 1 | 2016-08-10 11:07:22 | 2016-08-15 14:15:10 | | 2 | 8100009547 | 2016-06-21 | 2 | Dikirim | 81-9547.pdf | 2 | 2 | 1 | 2016-08-10 11:10:51 | 2016-08-15 14:14:46 | | 3 | 8100008792 | 2016-04-27 | 2 | Dikirim | po 8100008792.pdf | 2 | 2 | 1 | 2016-08-10 11:13:25 | 2016-08-15 14:14:11 | | 4 | 8100008436 | 2016-03-29 | 2 | Dikirim | PO 8100008436.pdf | 2 | 2 | 1 | 2016-08-10 11:15:12 | 2016-08-15 14:20:40 |
Query Varchar
SELECT * FROM `purchase_order` WHERE status = '0' # output +-----+-------------+------------+---------+--------+----------+------------+------------+--------+---------------------+---------------------+ | id | po_number | po_date | site_id | status | file_pdf | updated_by | created_by | active | created_at | updated_at | +-----+-------------+------------+---------+--------+----------+------------+------------+--------+---------------------+---------------------+ | 173 | F60794 | 2016-09-01 | 28 | 0 | NULL | 4 | 4 | 1 | 2016-09-02 09:25:05 | 2016-09-02 09:25:05 | | 190 | HAI12880807 | 2016-10-06 | 28 | 0 | pdf.pdf | 1 | 1 | 1 | 2016-10-06 12:37:00 | 2016-10-07 22:50:38 | +-----+-------------+------------+---------+--------+----------+------------+------------+--------+---------------------+---------------------+
karena tipe data 0 adalah char, maka harus dalam tanda petik, kalo ngga hasilnya akan beda.