利用Java理解sql的语法(实例讲解)

网友投稿 266 2023-03-15


利用Java理解sql的语法(实例讲解)

select 相当于 for 循环

select id from IDArray

LinkedList a = new LinkedList();

for ( int i=0 ; i

a.add(IDArray.get("id" ) );

}

return a;

当执行子查询时,可以理解为

select id, ( select name from nameArray) as names ,from Idarray

LinkedList a = new LinkedList();

for ( int i=0 ; i

a.add(IDArray.get("id" ) );

for(int j=0 ; j

a.add(namesArray.get("name"));

}

}

很明显这里一对多了。所以执行不对。报SQL错误

所以在 select中,应该要具体确定某一个值

select id, ( select name from nameArray where nameId=id) as names from Idarray

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArrahttp://y.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

当且仅当if 条件的值搜索是单个值的时候,是对应上的

那么groupBy呢?

select id, ( select nJlBRtMame from nameArrahttp://y where nameId=id) as names from Idarray group by id

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

a.add(IDArray.get("id" ) );

}

return a;

当执行子查询时,可以理解为

select id, ( select name from nameArray) as names ,from Idarray

LinkedList a = new LinkedList();

for ( int i=0 ; i

a.add(IDArray.get("id" ) );

for(int j=0 ; j

a.add(namesArray.get("name"));

}

}

很明显这里一对多了。所以执行不对。报SQL错误

所以在 select中,应该要具体确定某一个值

select id, ( select name from nameArray where nameId=id) as names from Idarray

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArrahttp://y.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

当且仅当if 条件的值搜索是单个值的时候,是对应上的

那么groupBy呢?

select id, ( select nJlBRtMame from nameArrahttp://y where nameId=id) as names from Idarray group by id

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

a.add(IDArray.get("id" ) );

for(int j=0 ; j

a.add(namesArray.get("name"));

}

}

很明显这里一对多了。所以执行不对。报SQL错误

所以在 select中,应该要具体确定某一个值

select id, ( select name from nameArray where nameId=id) as names from Idarray

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArrahttp://y.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

当且仅当if 条件的值搜索是单个值的时候,是对应上的

那么groupBy呢?

select id, ( select nJlBRtMame from nameArrahttp://y where nameId=id) as names from Idarray group by id

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

a.add(namesArray.get("name"));

}

}

很明显这里一对多了。所以执行不对。报SQL错误

所以在 select中,应该要具体确定某一个值

select id, ( select name from nameArray where nameId=id) as names from Idarray

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArrahttp://y.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

当且仅当if 条件的值搜索是单个值的时候,是对应上的

那么groupBy呢?

select id, ( select nJlBRtMame from nameArrahttp://y where nameId=id) as names from Idarray group by id

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArrahttp://y.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

当且仅当if 条件的值搜索是单个值的时候,是对应上的

那么groupBy呢?

select id, ( select nJlBRtMame from nameArrahttp://y where nameId=id) as names from Idarray group by id

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

if ( nameArrahttp://y.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

当且仅当if 条件的值搜索是单个值的时候,是对应上的

那么groupBy呢?

select id, ( select nJlBRtMame from nameArrahttp://y where nameId=id) as names from Idarray group by id

LinkedList a = new LinkedList();

for ( int i=0 ; i

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

Object object = IDArray.get("id" ) ;

for ( int j=0 ; j

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

if ( nameArray.get("nameId")==object){

Object object2 = nameArray.get("nameId");

a.add(object2);

}

}

a.add(object);

}

LinkedList groupByArray = new LinkedList();

for ( int i=0 ; i< a. length ; i++){

int id = a[i].getId();

LinkedList tempArray = new LinkedList();

for ( int j=0 ; j

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}

int temp = a[j].getId();

if ( id==temp){

tempArray.add(temp);

}

}

groupByArray.add(tempArray);

}


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:开票接口测试用例(开票软件测试连接失败)
下一篇:java对外接口开发规范(java接口开发需要注意什么)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~