студия открытых решений о-никс
<< Flow-tools Узнать внешний IP >>

MySQL command line (cli, командная строка)

How to Save results from MySQL into an external file
1. From the MySQL command line
SELECT columns FROM table_name WHERE whatever='something' INTO OUTFILE "/tmp/outfile.txt";

2. From the command line
2.A. Piping the SQL into the database
echo "SELECT columns FROM table_name
WHERE whatever='something'" | /path/to/mysql -uUSERNAME -pPASSWORD DATABASENAME > /tmp/outfile.txt;


2.B. Using an external SQL file.
/path/to/mysql -uUSERNAME -pPASSWORD DATABASENAME < /tmp/sql.sql > /tmp/outfile.txt;

Источник: http://www.liamdelahunty.com/tips/linux_grep.php

Выборка sql-запосом из двух и более таблиц
select a.some_id,a.some_name,a.something,b.description
from table1 a, table2 b
where a.some_id=b.some_id and b.description
like '%wtf%' INTO OUTFILE "/tmp/export.txt";

SELECT table1.column1, table2.column2
FROM table1, table2, table3
WHERE table1.column1 = table2.column1 AND table1.column1 = table3.column1;

select e1."Event_Name", v2."Venue"
from "events" e1, "venues" v2
where (e1."VenueNo" = v2."VenueNo")
order by e1."Event_Name" asc, v2."Venue" asc

<< Flow-tools Узнать внешний IP >>

Поделиться в соцсетях:

система комментирования CACKLE
RSS