Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to query all tables mysql at the same time

function searchAllDB($search){
    global $mysqli;

    $out = "";

    $sql = "show tables";
    $rs = $mysqli->query($sql);
    if($rs->num_rows > 0){
        while($r = $rs->fetch_array()){
            $table = $r[0];
            $out .= $table.";";
            $sql_search = "select * from ".$table." where ";
            $sql_search_fields = Array();
            $sql2 = "SHOW COLUMNS FROM ".$table;
            $rs2 = $mysqli->query($sql2);
            if($rs2->num_rows > 0){
                while($r2 = $rs2->fetch_array()){
                    $column = $r2[0];
                    $sql_search_fields[] = $column." like('%".$search."%')";
                }
                $rs2->close();
            }
            $sql_search .= implode(" OR ", $sql_search_fields);
            $rs3 = $mysqli->query($sql_search);
            $out .= $rs3->num_rows."
";
            if($rs3->num_rows > 0){
                $rs3->close();
            }
        }
        $rs->close();
    }

    return $out;
}
Comment

PREVIOUS NEXT
Code Example
Sql :: select from where 
Sql :: custom row number 
Sql :: PostgreSQL random boolean for generate test values 
Sql :: oracle user used size 
Sql :: mysql_error replacement 
Sql :: error access to system table innodb is rejected 
Sql :: SQL Copy Records Matching a Condition 
Sql :: what to do if foreign key is making conflict while deleting record from sql table using c# 
Sql :: select from 3 tables one is empty 
Sql :: postgresql get tables where column is foreign key 
Sql :: sql queries for interview 
Sql :: sql queries questions 
Sql :: practice sql queries 
Sql :: how to find constraints on a table in oracle 
Sql :: what is sql clause 
Sql :: stored procedure vs view 
Sql :: fatal database postgres does not exist 
Sql :: pl sql round 
Sql :: ffeathers express mysql application users login 
Csharp :: asp.net data annotations email 
Csharp :: unity how to change max fps 
Csharp :: c# create a text file 
Csharp :: vb.net wait 1 second 
Csharp :: how to stop window from terminating c# visual studio 
Csharp :: how to unlock cursor in unity 
Csharp :: c# format string to date yyyymmdd 
Csharp :: Animator.GotoState: State could not be found 
Csharp :: initialise icollection c# 
Csharp :: decode base64 string c# 
Csharp :: unity deactive code from code 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =