Hello! I have a sql query of the form:

SELECT * FROM `categories` WHERE `id` = '".str_clean($_GET['id'])."'" 

I need to pull out with the help of a single query all categories from the table, and one category whose id matches str_clean ($ _ GET ['id'])

Ie should get something like:

 SELECT * FROM `categories` && SELECT * FROM `categories` WHERE `id` = '".str_clean($_GET['id'])'" 

    2 answers 2

    This can be done, but what is the meaning of your request? What is the point of combining the full sample with a sample by id , if the first one includes the second one?

    SQLFiddle.com Code

    • @ ua6xh and then how to parse the array? - Lektor
    • @Lektor - which array? Query result? So you somehow displayed the results of the query before, right? here too. - Opalosolo
    • @ ua6xh Yes true, PHP - Lektor
    • @Lektor - Well, do you have written code to access the database? If not, then [learn] [1] how to do it. [1]: php.net/manual/ru/mysqli.quickstart.statements.php - Opalosolo
    • one
      Some kind of nonsense. In general, a reasonable answer was given by @Node_pro, but if you really want to throw off the selection of the active category on the DBMS, then you just need to add to the IF -selection box. - Indifferent

    And if you make `SELECT * FROM categories, and then make a check using php

     if($row['id'] == str_clean($_GET['id'])) //...