I want to display all data in my Database without writing a select
for each table - how can I do this?
I do not want to do this:
select * from Customer
select * from Employee
select .............
I am using TSQL with MSSQL Server.
There are many ways to display data from more than one table. You can join tables or views by a common column. You can also merge data from two or more tables or views into a single column or create a subquery to retrieve data from several tables. You can use a SELECT statement to join columns in two or more tables.
The first command you will need to use is the SELECT FROM MySQL statement that has the following syntax: SELECT * FROM table_name; This is a basic MySQL query which will tell the script to select all the records from the table_name table.
DECLARE @sqlText VARCHAR(MAX)
SET @sqlText = ''
SELECT @sqlText = @sqlText + ' SELECT * FROM ' + QUOTENAME(name) + CHAR(13) FROM sys.tables
EXEC(@sqlText)
For mysql:
Run SELECT information_schema.TABLES.TABLE_NAME FROM information_schema.TABLES where table_schema='db_name'
Create a loop which will run select query for each table gotten from the first query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With