|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Join Date: Oct 2003
Location: Blacksburg, VA
Posts: 65
Reputation: 5
|
Using WHERE in MySQL query
If I have two variables:
$start $end How would I query entries from a data base with dates between $start and $end Would it be something like: SELECT id, date FROM my_db_table WHERE date>=$start && date<=end ORDER BY date ASC thanks, sam |
|
|
|
|
#2 |
|
foo
Join Date: Jan 2003
Location: Seattle-ish
Posts: 2,597
Reputation: 106
|
Correct, except that it would be $end, not end.
__________________
webhead.cc |
|
|
|
|
#3 |
|
Posts: n/a
|
expr BETWEEN min AND max
almost...
the and operator in SQL is "AND", not "&&". It's also a good idea to use identifiers "`" if you have a filed name like date. Code:
You can also use the BETWEEN operator. It does the same thing, but it's a little easier to read. Code:
|
|
|
#4 |
|
Join Date: Oct 2003
Location: Blacksburg, VA
Posts: 65
Reputation: 5
|
thanks
|
|
|
|
|
#5 |
|
foo
Join Date: Jan 2003
Location: Seattle-ish
Posts: 2,597
Reputation: 106
|
I thought mysql allows &&
http://dev.mysql.com/doc/mysql/en/Lo...Operators.html
__________________
webhead.cc |
|
|
|
|
#6 | |
|
Posts: n/a
|
Quote:
. I've been using SQL (not mySQL) for many years and I've never seen && used in a WHERE. Thanks |
|
|
|
#7 |
|
Join Date: Oct 2003
Location: Blacksburg, VA
Posts: 65
Reputation: 5
|
building on but not directly related to...
If I have a string:
Code:
And then calculate the value of $number (let's say $number = 3) How do I successfully echo/print out: rowspan=3 using something to the effect of Code:
right now it just prints rowspan = $number |
|
|
|
|
#8 | |
|
Posts: n/a
|
Quote:
If you can assign a value to $number before you create the $output variable. Code:
If the value of $number is unkown, you can use this approach. Code:
|
|
|
|
#9 |
|
foo
Join Date: Jan 2003
Location: Seattle-ish
Posts: 2,597
Reputation: 106
|
mysql is not very strict about complying to standards. That's why you can insert strings into int columns
![]() This is perfectly valid to mysql: INSERT INTO table (some_int_col) VALUES ('3');
__________________
webhead.cc |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|