mysql計算的結果匯出 mysql 匯出查詢結果

2021-10-18 17:16:15 字數 563 閱讀 8266

select * from my_table into outfile '/tmp/abc.xls';

然後就是ftp把檔案弄回本地了。我的是程式自動放到c:\下

另外,還有一種匯出的方式,相較於上者而言,這種可以對已經存在的檔案直接覆蓋。

//使用outfile的方法

mysql> select 1 into outfile '/tmp/t1.txt';

query ok, 1 row affected (0.00 sec)

mysql> select 1 into outfile '/tmp/t1.txt';

error 1086 (hy000): file '/tmp/t1.txt' already exists

只能匯出到tmp目錄下,其他目錄會報錯

另一種方法:

指令碼匯出:

#!/bin/bash

cat << endf | mysql -u root -proot > tmes.txt

select * from test.1_account;

endf

注意新增資料庫.表名稱

mysql對結果計算 MYSQL計算結果

我正在 mysql 5.0中構建乙個查詢來計算學生的學期成績.初始表 studentitemgrades 包含將用於計算最終成績的作業列表等.每項作業都有乙個possiblescore,grade和weight.計算應對所有類似加權的專案進行分組,並根據分配到期的日期範圍提供sum grade su...

筆記 mysql 匯出查詢結果

語法 the select into outfile file name options form of select writes the selected rows to a file.示例 select from students into outfile test users.csv fie...

MYSQL匯出查詢結果到檔案

select order id product name qty from orders into outfile data data.txt select order id product name qty from orders into outfile tmp orders.csv field...