Page 1 of 1

using SUBSTING() in WHERE CLAUSE

Posted: Fri Aug 08, 2003 3:35 pm
by kendall
Hello,

I have a table

create table individuals values (id, fname, mname, lname, born, died)

i have a form that has input fields name, year, month , day with a boolean AND/ OR option.

the theory...to be able to query the data by fname or mname or lname or year or month or day

now for the nam part i have opted to use a FULLTEXT Index search

but can i do a SUBSTRING(Date,exp ) in a WHERE CLAUSE?

what other otpions i have?

Kendall

Posted: Fri Aug 08, 2003 4:20 pm
by Crashin
Try using this instead:

Code: Select all

EXTRACT(interval FROM datetime)
Your intervals can be any of those listed on this page relative to the DATE_ADD function:

http://www.mysql.com/doc/en/Date_and_ti ... tions.html

For example:

Code: Select all

... WHERE EXTRACT(MONTH FROM 'born') = $bornMonth
8)

using SUBSTING() in WHERE CLAUSE

Posted: Sat Aug 09, 2003 12:49 pm
by kendall
Crashin,

Yo man...I can't get it to work...are you sure this can be used there?...I'm scouring the mysql documentation but i the def. are really vague(i find there search method really unreliable)

Kendall

Posted: Sat Aug 09, 2003 12:57 pm
by kendall
ok,

i see my mistake

I quoted the column

thus it should be WHERE EXTRACT(YEAR FROM Born) = $year

thanks

Posted: Mon Aug 11, 2003 9:28 am
by Crashin
Cool! I'm glad it worked for you! 8)