十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶(hù) + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專(zhuān)業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
mysql中,可用庫(kù)名前綴同時(shí)查詢(xún)兩個(gè)數(shù)據(jù)庫(kù)中的數(shù)據(jù)。
成都創(chuàng)新互聯(lián)專(zhuān)注為客戶(hù)提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都做網(wǎng)站、成都網(wǎng)站制作、安澤網(wǎng)絡(luò)推廣、小程序制作、安澤網(wǎng)絡(luò)營(yíng)銷(xiāo)、安澤企業(yè)策劃、安澤品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供安澤建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com
工具:mysql 5.6
步驟:
1、如圖可見(jiàn),在本地localhost中有2個(gè)數(shù)據(jù)庫(kù),分別是badkano和badkano_test。
2、假如兩個(gè)數(shù)據(jù)庫(kù)中有相同的表student,數(shù)據(jù)分別如下:
3、要同時(shí)查詢(xún)兩個(gè)數(shù)據(jù)庫(kù)中的上邊兩張表,語(yǔ)句如下:
select?*?from?badkano.studentunion?all?select?*?from?badkano_test.student;
4、查詢(xún)結(jié)果就將2個(gè)庫(kù)中的數(shù)據(jù)一起查出來(lái)了:
create function myLength(@col varchar(1000)) returns int
as
begin
declare @v int
set @v=1
declare @i int
set @i=charindex('|',@col)
while(@i0)
begin
set @v=@v+1
set @col=substring(@col,@i+1,len(@col))
set @i=charindex('|',@col)
end
return @v
end
go
select dbo.mylength('123') //結(jié)果是1
select dbo.mylength('|123') //結(jié)果是2
select dbo.mylength('|123|') //結(jié)果是3
你的語(yǔ)句就可以用:
select * from 表 where dbo.mylength(a) dbo.mylength(b)
--注意函數(shù)名前要加dbo.
update pre_forum_typeoptionvar set value = (select subject form pre_forum_thread where pre_forum_thread.tid = (select tid from pre_forum_typeoptionvar where optionid=33))