This question already has answers here:
"Show databases" with condition
(4 answers)
Closed 5 years ago.
Is there a way to show a list of databases by condition?
Show databases WHERE table_name ='?' AND column_name = '?';
BEST BET:
Just itterate through all the databases, but if your trying to find a specific table why not just do this SHOW TABLES LIKE 'my_table_numer_%'; That will select a table with a begging part followed by a wild card text.
Related
This question already has answers here:
php and mysql copy record from one table to another
(4 answers)
Closed 3 years ago.
Is there any easy way to copy one a column in a table to another table without changing the order ?
I am a beginner here. I would be much thankful to you if you could supply in depth answer.
I think this query can help you out
INSERT INTO second_table SELECT * FROM first_table WHERE id IN(1,2,3,4...n)
This question already has answers here:
Get table column names in MySQL?
(19 answers)
Closed 6 years ago.
how do I display mysql "field" column only on my website using PHP and SQL? I don't want to show other data except the "field" column in a table.
Because I trying to do adding,editing and deleting of the "field" through my own website admin portal instead of login to phpmyadmin to do it. Appreciate if have advice on this too.
Thanks[please refer to the picture below for easier understand what I'm asking]
https://i.stack.imgur.com/WVGQl.png
Your query should be this:
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '<database_name>' AND TABLE_NAME = '<table_name>';
This question already has answers here:
php pdo: get the columns name of a table
(14 answers)
Closed 7 years ago.
How would you fetch a mysql query with PDO (Or after PDO) in order to have this result? I mean the "titles of the columns" in the first position of the array and the values in the next positions? Can somebody helping me with an example?
[
["ColumnTitle","Column2Title"],
["RecordValue1","RecordValue2"],
["RecordValue1","RecordValue2"],
["RecordValue1","RecordValue2"],
["RecordValue1","RecordValue2"]
]
The mysql query returns:
ColumnTitle | Column2Title
----------------------------
RecordValue1 RecordValue2
RecordValue1 RecordValue2
RecordValue1 RecordValue2
RecordValue1 RecordValue2
I don't think this question was duplicate, this was a specific case.. :(
PDO doesn't offer such a format out of the box (because no developer would like it this way), but you can make it with minor tweaking
$data = $pdo->query('SELECT * FROM users')->fetchAll(PDO::FETCH_ASSOC);
array_unshift($data, array_keys($data));
But in your place I wouldn't add column names to the data array at all.
This question already has answers here:
Select data from "show tables" MySQL query
(13 answers)
Closed 9 years ago.
Blockquote
sir i want to fetch all the table's name and information about all table as total no. of field etc with the help of single query in php file .i am using phpmyadmin as mysql please tell me how can i do it.
thanks
select * from information_schema.TABLES
You can also check :
select * from information_schema.COLUMNS
This question already has answers here:
PHP Mysql joins across databases
(4 answers)
Closed 9 years ago.
Is it possible to join 2 different databases in mysql using php?
for instance:
$sql = "SELECT * FROM db1.table LEFT JOIN db2.table USING (id)";
$result = mysql_query($sql);
--
I know how to create multiple new different database connections using php. But I'm unable to figure out if it's possible to acutally join two different databases in mysql using php in one query.
I believe you can do it simply like:
SELECT DB1Table.columnIWant, DB2Table.ColumnIWant
FROM DB1.AppropiateTable as DB1Table
JOIN DB2.TableToJoin as DB2Table
ON DB1Table.ID = DB2Table.ID
Assuming the user is auth'ed for both tables. Also - see this link on multiple connections:
How do you connect to multiple MySQL databases on a single webpage?