Gossamer Forum
Home : General : Databases and SQL :

Help with SQL wildcard statement

Quote Reply
Help with SQL wildcard statement
Hi All,

I need to pull information from a database where information in a field = a number, but not 0 so if the field has 1 - 1000 in it it will return the infomation

but if it has 0 it will skip it.

Does this make sense, and can it be one??
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
You could try the following:

WHERE (column BETWEEN 1 AND 1000)
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
Alternatively:

WHERE column > 0 and column < 1001

will also do the trick.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Help with SQL wildcard statement In reply to
So if i put > 1 it will find everything above 1 but not 0
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
Mmm, OK.

If i put > 0 it lists everything including the 0

If i put > 1 it lists everything but omits 0 and 1

Is this right?
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
Hi Guys,

Im still having problems here.

I've been searching the MySQL sites and found that i need to use >= 1 to list everything above 1 and including 1 but its still listing records with 0 in this field.

Code:
$query = qq{select order_d.order_recur_id,order_d.domain_name,order_d.domain_id from order_d,order_m where order_m.order_id=order_d.order_id and order_m.user_id=$user_id and order_d.plan_id >= 1 order by order_m.order_id };


Its driving me mad!!!
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
I would try using LEFT JOIN for the join for your tables rather within the WHERE clause to join PK and FK.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Help with SQL wildcard statement In reply to
You've totaly lost me there!!!

I didnt write the script/s im just trying to add mor fuctionality to them.

Could you explain.
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
ok...(i'd suggest really suggest reading on JOINS in the MySQL website)....but here is what I mean:

Code:
$query = qq{select order_d.order_recur_id,order_d.domain_name,order_d.domain_id from order_d LEFT JOIN order_m ON m.order_id = order_d.order_id where order_m.user_id=$user_id and order_m.plan_id >= 1 order by order_m.order_id };

I also changed the order_d.plan_id >= 1 to order_m.plan_id >=1.

Hope this helps.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Help with SQL wildcard statement In reply to
Right, OK i will give that a try.

but something has confused me.

plan_id doesnt exist in the order_m table only order_d and you said it should be changed, will it still work?
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
Mmm,

Well it doesnt work either way, i get a reply, "there are no domains" which obviously there are.

Would it be better to see the whole script?
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
Possibly, since there may be other codes that are prohibiting you for obtaining your goal.

Sorry about the change with the plan_id.

It would also help to see the schema of the two tables in question.

Also, since you mentioned earlier that you wanted records between 1 and 1000, did you try using the BETWEEN function in the WHERE clause as I originally recommended.
========================================
Buh Bye!

Cheers,
Me

Last edited by:

Stealth: Jul 22, 2003, 7:43 PM
Quote Reply
Re: [Stealth] Help with SQL wildcard statement In reply to
Ok,

Yes i tried the between but with no luck

order_d
order_recur_id order_id domain_name domain_id domain_period_yr domain_amount domain_date plan_id plan_duration_mnth plan_amount plan_date domain_reg domain_renew

order_m
order_id user_id total_amount ord_date

Ive emailed the file seperately
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
It would help (for other users who may also want to help you) to have the file uploaded in the forum as well.

I looked at the script and doesn't look like anything is out of order, although the JOIN codes are still not correct...I may have mis-typed the codes above.

It should look like the following:

Code:
from order_d LEFT JOIN order_m ON order_m.order_id = order_d.order_id
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Help with SQL wildcard statement In reply to
OK
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!
Quote Reply
Re: [mdj1] Help with SQL wildcard statement In reply to
Thanks Stealth!!

It now seems to be working



HURRAHH!!
Regards

Mark
http://www.host4.me.uk

No doubt i'll be back for more answers!