Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

Filter MySQL Select results

Status
Not open for further replies.
I dont know if I am understanding you correctly, but if I am then these are just AND conditions.

So, lets say we have the following base query:

SELECT * FROM outdoors WHERE type = 'bikes';

This would send back all bikes from the outdoors database, but to filter it further to, lets say road bikes, it would be:

SELECT * FROM outdoors WHERE type = 'bikes' AND kind = 'road';

You can utilise a user check-box to filter results in this way. Apologies in advance if I have misunderstood you.
 
On my phone so can't go in to great detail, but it might be easier to explain to you if you explain exactly what you're trying to do.

As mentioned above, the WHERE clause is all you need really. Or you could have something like:

Select * from customers where creditLimit between 1000 and 2000;

Look up SQL on W3Schools, it explains pretty much everything. Only thing is that MySQL is a tiny tiny bit different syntax at times.

SQL / MySQL is one of my favourite languages really, since it's nearly like English!

Sent from my GT-I9300 using Tapatalk 2
 
For stuff like this, I use an php if selector,

$radio = defang($_POST['rdBox']);
if($radio==?){
$q = "select a, b, c from x where y = ?;";
} else {
$q = "select a, b, c from x where y = ? and z = ??;";
}

then load the query as normal
 
Also, be aware of SQL injection if you use any of the POST/GET values in the SQL query.

If you have a small data set, then select * is OK, however, if there s a lot of data, just select the actual data you intend to use on the page and make use of the LIMIT clause so you are not pulling back data that will never actually be displayed, this will keep the server load in check.
 
Status
Not open for further replies.

Rule #1: Be Respectful

Do not insult any other member. Be polite and do business. Thank you!

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Siusaidh AcornBot:
    Siusaidh has left the room.
      Siusaidh AcornBot: Siusaidh has left the room.
      Top Bottom