search

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bxm_3
Forum Newbie
Posts: 13
Joined: Sun Nov 20, 2005 6:23 pm

search

Post by bxm_3 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am trying to search all possible penpals by gender and country, maybe including the county if it is selected and I wish to select penpals within a date of birth (d1,m1,y1), (d2,m2,y2), if y2<y1 or y2> y1, limiting the first ten correct results.

is the right sql code

[syntax="sql"]select from penpal GENDER='$gender' AND COUNTRY='$country' and COUNTY='$county' or COUNTRY='$country' and
'$m1' <MONTHOFBIRTH and '$y1'=YEAROFBIRTH or '$d1'<DAYOFBIRTH and '$m1' =MONTHOFBIRTH and '$y1'=YEAROFBIRTH or '$d2'>DAYOFBIRTH and '$m2' =MONTHOFBIRTH and '$y2'=YEAROFBIRTH or
'$m2' >MONTHOFBIRTH and '$y2'=YEAROFBIRTH or '$y2' <YEAROFBIRTH and '$y1'>YEAROFBIRTH LIMIT 0,10"

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm having a tough time understanding what you're wanting to do let alone your query. An you try to explain the logic a bit more?

On a side note, why are you storing the dates of birth as separated fields?
Post Reply