SQL Search Specifies

-1

Ola wanted to do a search in the database with and that only bring the response if conditions are reached used code.

$sql2 ="SELECT * FROM 'link' WHERE 1  LIKE ds_url_orig='https://www.frasesdobem.com.br/frases-incriveis' AND ds_email_link_modo='0'";
                $query2 = mysqli_query($link, $sql2) or die(mysqli_error());
                $show2 = mysqli_fetch_array($query2);
                $email_type = $show2['ds_email_link_modo'];

                while($rows = mysqli_fetch_array($query2)){
                    $email_type  =$rows['ds_email_link_modo'];
                    echo $email_type.'/';
                }

If ds_url_orig is found and ds_email_link_modo is equal to the one it queried it shows, and if one of them is false it does not show result. However the code continues to show if a condition is true someone can help me

    
asked by anonymous 20.03.2018 / 16:34

1 answer

2

You are currently using LIKE incorrectly.

Correct:

SELECT * 
FROM 'link' 
WHERE ds_url_orig LIKE '%https://www.frasesdobem.com.br/frases-incriveis%' 
AND ds_email_link_modo = '0'

Also, if you only have numbers in ds_email_link_modo , you will not usually need quotes, unless it's something very specific.

AND ds_email_link_modo = 0

AND obligatorily obliges the first filter to be mandatory.

"Reading" your query would be basically like this:

Bring everything from table link , where ds_url_orig contains '%https://www.frasesdobem.com.br/frases-incriveis%' and ds_email_link_modo is equal to 0 .

The % in the LIKE means "anything before", and the end of "anything after" (can be removed)

    
20.03.2018 / 16:46