简体   繁体   中英

How to check for which version of MySQL is valid my query?

I'm trying to do some queries which in my local XAMPP is working fine, but, when I try on my server, the query shows empty.

I use phpinfo() to check MySQL version, on my local is 7.4 and on my server is 5.7. The thing is my SQL query is working on server, is not showing any errors, but the response is empty, this is not happening on local.

Query:

SELECT
    *,
    JSON_EXTRACT(`settings`, '$.exp') AS `exp`,
    JSON_EXTRACT(`settings`, '$.status') AS `status`
FROM
    `factory_invoice`
WHERE
    `invoice` REGEXP '^[0-9]{4}[A-Z]{3}$' AND(
        JSON_CONTAINS(`settings`, '1', '$.type') OR JSON_CONTAINS(`settings`, '2', '$.type')
    ) AND(
        JSON_EXTRACT(`settings`, '$.status') = '0' OR JSON_EXTRACT(`settings`, '$.status') = '1'
    ) AND(
        JSON_EXTRACT(`settings`, '$.exp') >= '1609153609' AND JSON_EXTRACT(`settings`, '$.exp') <= '1620770400'
    )
ORDER BY
    `invoice` ASC

Any idea if is something from the server side? Or maybe from my SQL query?

I already solved. The problem was in JSON_EXTRACT( settings , '$.exp') >= '1244.... Thanks to @AsifUzZaman

I just clean a bit the code and I use BETWEEN method.

SELECT
    *
FROM
    `factory_invoice`
WHERE
    `invoice` REGEXP '^[0-9]{4}[A-Z]{3}$' AND JSON_EXTRACT(`settings`, '$.type') IN(1, 2) AND JSON_EXTRACT(`settings`, '$.status') IN(0, 1) AND JSON_EXTRACT(`settings`, '$.exp') BETWEEN '1609110000' AND '1620770400'
ORDER BY
    `invoice` ASC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM