开发者

Mysql: searching through all rows with equal values in one colum

I'm trying to select all rows that开发者_如何学JAVA contain the same value in one column and search the selected rows.

For example:

column1 column2 column3 column4 column5
cool    4       55      0       1/2/1999
peeps   3       44      4       12/15/2010
great   4       23      1       3/4/2002
ok      5       12      5       4/27/2003
huh     4       25      7       5/16/2004

I have to search for a specific value within the rows, in this case I would be selecting rows in column 2 with the value of 4. Then searching those rows for dates.


To get all dates where column2 = 4:

select column5 from table where column2 = 4

If you want to also restrict by a date range:

select * from table where column2 = 4 and column5 >= '1999-01-02' and column5 <= '2004-05-16'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜