SQL子字符串语句

时间:2018-07-01 20:25:54

标签: sql

我偶然发现了我不熟悉的这种SQL查询。 构建选择语句后,“新”事物有什么明显的特点?

substring((select group_concat(new.card_number,0x0a,new.card_holdername) from 
(select id,card_number,card_holdername from credit_cards) new where new.id=1), 
1, 300)

2 个答案:

答案 0 :(得分:1)

在SQL中,每个 class A{ public: int a; A(int a){ this->a = a; } A(){} friend ostream& operator<<(ostream& os, const A& dt); A operator()(int n){ //changes the current a to n this->a = n; return *this; } ostream& operator<<(ostream& os, const A& objectA){ os << objectA.a<<endl; return os; } int main() { A a(1500); cout<<a(1200); return 0; } 语句都会返回一个表。每个表都需要有一个名称。这称为别名。您可以对列执行相同的操作,使它们为正在执行的特定查询提供其他名称


在您的示例中,中间表名为SELECT,创建该表的查询为:

new

在外部查询中,您可以像下面这样引用此select id,card_number,card_holdername from credit_cards 表中的列:

new

答案 1 :(得分:0)

new是别名,在您的示例中,它是此select的别名:

(select id,card_number,card_holdername from credit_cards) new 

因此,这些是您的new表中的引用:

.card_number,0x0a, .card_holdername ..