fetch data from mysql table using php ignoring some values?

125
October 27, 2018, at 10:40 AM

I have a table which have a column with name domain_name. in domain_name column, different values stores like google.com, facebook.com, twitter.com etc. I try this which is working.

$query= 'Select * from accountdb WHERE domain_name="twitter.com" order by domain_name ASC';

But I want to pick that rows which have the values facebook.com, twitter.com in one query. I try this to achieve but not working.

$query= 'Select * from accountdb WHERE domain_name="twitter.com" and domain_name="facebook.com" order by domain_name ASC';

Alterring quotes

$query= "Select * from accountdb WHERE domain_name='twitter.com' and name='facebook.com' order by domain_name ASC";

Any hint would be appreciated.

Answer 1

And means that both conditions have to be met which will never ever happen. You want domain_name to be either "twitter.com" or "facebook.com". So you have to use or

$query= 'Select * from accountdb WHERE domain_name="twitter.com" or domain_name="facebook.com" order by domain_name ASC';

If you have more than 2 domains to check, best way is to use in.

$query= 'Select * from accountdb WHERE domain_name in ("twitter.com","facebook.com","google.com") order by domain_name ASC';
Answer 2
You can use OR.
$query= 'Select * from accountdb WHERE domain_name="twitter.com" OR domain_name="facebook.com" order by domain_name ASC';
Rent Charter Buses Company
READ ALSO
mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters

mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters

My php form inserts a few columns and an encrypted password into my tableHowever when I run it it says the variable number doesn't match the number of parameters

160
how to make after user logged in the php website, they can view his personal data only

how to make after user logged in the php website, they can view his personal data only

I am working on internal payslip portal using php, so my question is when user logged in this portal they have access to view any ones data, so i want to make restrictions to users when they login they only visible his personal data only,like google...

114
Problem to update row in Laravel 5.7, doesnt work

Problem to update row in Laravel 5.7, doesnt work

I have a little problem with function update in laravel

152
How to search for encrypted value using Laravel Eloquent ORM?

How to search for encrypted value using Laravel Eloquent ORM?

I've got a Laravel codebase which records are encrypted before they are inserted in the Mysql databaseIf I want to find a record based on one of the encrypted values, looping over all the records works:

124