mysql 日期比较有关问题
mysql 日期比较问题
现在表kucun中有datavalue(varchar,是2012-01-01这样的格式日期)和price(float 11,2)字段
现在我想获取2012-07-10到2012-08-10中的数据我的写法是这样的
1,
SELECT * FROM `kucun` where datavalue between 'UNIX_TIMESTAMP(2012-07-10)' and 'UNIX_TIMESTAMP(2012-08-10)'
结果为空
2,
SELECT * FROM `kucun` WHERE datavalue BETWEEN '2012-07-10' AND '2012-08-10'
结果正确,获取我想要找的数据了
3,
SELECT * FROM `kucun` where UNIX_TIMESTAMP(datavalue)>UNIX_TIMESTAMP(2012-07-10) and UNIX_TIMESTAMP(datavalue)
为么1和3在为空呢?2这样写正规吗?XXXX-XX-XX 这样的格式日期可以比较吗?
------解决方案--------------------
1、
SELECT * FROM `kucun` where datavalue between 'UNIX_TIMESTAMP(2012-07-10)' and 'UNIX_TIMESTAMP(2012-08-10)'
要删去多余的引号
3、
SELECT * FROM `kucun` where UNIX_TIMESTAMP(datavalue)>UNIX_TIMESTAMP('2012-07-10') and UNIX_TIMESTAMP(datavalue)
------解决方案--------------------
UNIX_TIMESTAMP()函数的字符串参数要加引号,这样试试:
- SQL code
SELECT * FROM `kucun` where UNIX_TIMESTAMP(datavalue)>UNIX_TIMESTAMP('2012-07-10') and UNIX_TIMESTAMP(datavalue)<unix_timestamp class="clear"> </unix_timestamp>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



GNU is a Unix-like operating system developed and designed based on Unix and is compatible with Unix. GNU consists of a set of software applications and developer tools and a program that allocates resources and communicates with hardware or the kernel. GNU can be used with other kernels, and is usually used with the Linux kernel. GNU programs can be ported to many other operating systems, including different platforms such as Mac OS X and Microsoft Windows.

Unix is a multi-user, multi-process computer operating system that supports multiple processor architectures. According to the classification of operating systems, it is a time-sharing operating system. In addition to being a network operating system, Unix can also be used as a stand-alone operating system. The UNIX system provides a good user interface, which is easy to use, fully functional, clear and flexible, and easy to expand and modify.

After several pre-releases, the KDE Plasma development team unveiled version 6.0 of its desktop environment for Linux and BSD systems on 28 February, using the Qt6 framework for the first time. KDE Plasma 6.1 now comes with a number of new features t

The original intention of Linux was to replace UNIX and optimize its functions and user experience. Therefore, Linux imitated UNIX (but did not plagiarize the source code of UNIX), making Linux very similar to UNIX in appearance and interaction. Therefore, it can be said that "UNIX is the father of Linux". It is precisely because Linux and UNIX are inextricably linked that people call Linux a "UNIX-like system."

The timestamp refers to the total number of seconds from 00:00:00 on January 1, 1970, Greenwich Mean Time (08:00:00 on January 1, 1970, Beijing time) to the present. Various versions of MySQL are deployed in the production environment, including three major versions of MySQL 5.5/5.6/5.7 and N minor versions. Due to the poor upward compatibility of MySQL, the same SQL behaves differently in different versions. As follows The timestamp data type is introduced in detail from several aspects. Timestamp data access In the above three major versions of MySQL, the value range of the default timestamp (Timestamp) type is’1970-01-0100:00:01&r

1Unix philosophy The Unix philosophy emphasizes practicality, comes from rich experience, and is not restricted by traditional methodologies or standards. This knowledge is more latent and semi-instinctive. The knowledge that Unix programmers accumulate through development experience can benefit other programmers. (1) Each program should focus on completing one task and start over when encountering a new task to avoid adding new functions to the original program, resulting in increased complexity. (2) Assuming that the output of a program will become the input of another program, even if the next program is not clear, make sure that the output does not contain irrelevant information. (3) Put the designed and written software into trial use as soon as possible, and discard low-quality code decisively and rewrite it. (4) Use tools prior to inefficient auxiliary means to reduce the burden of programming tasks and strive for excellence.

The differences are: 1. UNIX is open source, while Win is proprietary software, and its source code is not open to the public; 2. UNIX is designed for multi-user, multi-task environments, while Win is suitable for individuals; 3. Win is more powerful than UNIX Easy to get started; 4. UNIX performs better than Win in terms of performance and stability; 5. Win has wider application and software compatibility than UNIX; 6. UNIX licenses are usually more expensive than Win; 7. UNIX has better security Performance is better than Win in terms of performance; 8. UNIX installation is simpler than Win.

Imitate the find command in the Unix operating system and implement a myfind command. The myfind command starts from the specified directory and searches for the specified file recursively. The command format is as follows: myfindPATH-option parameter [-print][-exec command {};]PATH: starting directory to search. -option parameter: Used to control the search method, the details are as follows (only the ones I commonly use are given below): -name "file": Specify the file name to be searched for. The Linux command locates the file. It can be escaped?*, etc. -prune directory: Do not search this directory when emphasizing search. -mtime+n or -n: Search linux command location files by time, +n: means
