需要MySQl查询

时间:2016-02-18 10:32:15

标签: mysql join

我有一张桌子

ID    Details   User_id Last_ID
2960    ABC     52294
10532   PQR     61629   61629
11050   XYZ     69

和其他

Id    UserName
69      aaaa
52294   bbbb
61629   cccc

请提供查询以获取以下数据

ID    Details   UserName last_id

4 个答案:

答案 0 :(得分:1)

查询:

SELECT a.ID, a.details, b.UserName, a.Last_ID
FROM one_table as a,
INNER JOIN other_table as b ON b.id = a.user_id

请参阅mysql join

答案 1 :(得分:0)

SELECT d.ID, d.Details, u.UserName 
FROM details d, usernames u 
WHERE d.User_id = u.Id

答案 2 :(得分:0)

border-right: 10px solid #5379A5;

答案 3 :(得分:0)

public class JsonSonAdapter extends ArrayAdapter<JsonSongs> {
ArrayList<JsonSongs> songList;
int Resource;
Context context;
LayoutInflater vi;

public JsonSonAdapter(Context context, int resource, ArrayList<JsonSongs> objects) {
    super(context, resource, objects);
    songList = objects;
    Resource = resource;
    this.context = context;
    vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder;
    if(convertView == null){
       convertView = vi.inflate(Resource,null);
        holder = new ViewHolder();
        holder.textJson_ID=(TextView)convertView.findViewById(R.id.textJson_ID);
        holder.textJSONname=(TextView)convertView.findViewById(R.id.textJSONname);
        holder.textJsonSong=(TextView)convertView.findViewById(R.id.textJsonSong);
        holder.textJsonYear=(TextView)convertView.findViewById(R.id.textJsonYear);
        holder.textJsonWeeks=(TextView)convertView.findViewById(R.id.textJsonWeeks);
        convertView.setTag(holder);
    }else {
        holder = (ViewHolder)convertView.getTag();
    }

    return convertView;
}

static class ViewHolder{

 public TextView textJsonYear;
 public TextView textJSONname;
 public TextView textJsonSong;
 public TextView textJsonWeeks;
 public TextView textJson_ID;
 }

}