小编Mar*_*tin的帖子

在MySQL子查询中选择多个列/字段

基本上有属性表和转换表 - 一个属性的许多翻译.

我需要为指定语言中的每个属性选择翻译的id和值,即使该语言中没有翻译记录.我错过了一些连接技术或连接(不涉及语言表)在这里不起作用,因为以下不返回具有指定语言的非现有翻译的属性.

select a.attribute, at.id, at.translation 
from attribute a left join attributeTranslation at on a.id=at.attribute
where al.language=1;
Run Code Online (Sandbox Code Playgroud)

所以我使用这样的子查询,这里的问题是使用相同的参数对同一个表进行两个子查询(感觉就像性能耗尽,除非mysql对那些组合,我怀疑它因为它会让你做很多类似的子查询)

select attribute, 
(select id from attributeTranslation where attribute=a.id and language=1),
(select translation from attributeTranslation where attribute=a.id and language=1), 
from attribute a;
Run Code Online (Sandbox Code Playgroud)

我希望能够从一个查询中获取id和翻译,所以我将列连接并稍后从字符串中获取id,这至少会产生单个子查询,但仍然看起来不正确.

select attribute,
(select concat(id,';',title)
    from offerAttribute_language 
    where offerAttribute=a.id and _language=1
)
from offerAttribute a
Run Code Online (Sandbox Code Playgroud)

所以问题部分.有没有办法从单个子查询中获取多个列,或者我应该使用两个子查询(mysql是否足够聪明地将它们分组?)或者加入以下方式:

[[语言属性]到翻译](加入3个表似乎比子查询更差).

mysql

53
推荐指数
1
解决办法
14万
查看次数

如何在jquery中获取子元素的数组

继承我的元素,我想通过循环它们来安排孩子们.

<div id="animDummy1">
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
Run Code Online (Sandbox Code Playgroud)

下面我想象代码看起来如何,但是当然,children()不会返回一个孩子的数组

var children=$('#animDummy1').children();
for(var i=0;i<children.length;i++){
    children[i].css('left',i*120+'px');
}
Run Code Online (Sandbox Code Playgroud)

问题 - 我可以在循环中使用子数组吗?我知道我可以附上每个要执行对儿童的功能,但我可以在那里"我"增加?

日Thnx.

jquery

21
推荐指数
3
解决办法
7万
查看次数

标签 统计

jquery ×1

mysql ×1