如何选择独特?

时间:2018-05-03 08:48:35

标签: postgresql knex.js

我正在制作一个现场音乐数据库,我想不出如何进行一个能够让有艺术家活动的艺术家的查询。

我有两个表: Failed to compile resources with the following parameters: -bootclasspath "C:/Program Files/Java/android-sdk-windows\platforms\android-27\android.jar" -d "C:\Game\3drq\superblocks\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "android\support\v4\Manifest.java" "android\support\v4\R.java" "com\cheerflame\superblocks\Manifest.java" "com\cheerflame\superblocks\R.java" "com\google\android\gms\Manifest.java" "com\google\android\gms\R.java" "com\google\android\gms\ads\Manifest.java" "com\google\android\gms\ads\R.java" "com\google\android\gms\ads\impl\Manifest.java" "com\google\android\gms\ads\impl\R.java" "com\google\android\gms\analytics\Manifest.java" "com\google\android\gms\analytics\R.java" "com\google\android\gms\appinvite\Manifest.java" "com\google\android\gms\appinvite\R.java" "com\google\android\gms\auth\Manifest.java" "com\google\android\gms\auth\R.java" "com\google\android\gms\auth\api\Manifest.java" "com\google\android\gms\auth\api\R.java" "com\google\android\gms\base\Manifest.java" "com\google\android\gms\base\R.java" "com\google\android\gms\drive\Manifest.java" "com\google\android\gms\drive\R.java" "com\google\android\gms\games\Manifest.java" "com\google\android\gms\games\R.java" "com\google\android\gms\gcm\Manifest.java" "com\google\android\gms\gcm\R.java" "com\google\android\gms\iid\Manifest.java" "com\google\android\gms\iid\R.java" "com\google\android\gms\plus\Manifest.java" "com\google\android\gms\plus\R.java" "com\stansassets\androidnative\Manifest.java" "com\stansassets\androidnative\R.java" "com\stansassets\billing\Manifest.java" "com\stansassets\billing\R.java" "com\stansassets\googleplay\Manifest.java" "com\stansassets\googleplay\R.java" "com\stansassets\mnp\Manifest.java" "com\stansassets\mnp\R.java" "com\stansassets\social\Manifest.java" "com\stansassets\social\R.java" ����: C:\Program Files\Java\android-sdk-windows\platforms\android-27\android.jar(java/lang/Object.class): ���汾 52 �� 51 ��, �˱�����֧�����µ����汾�����������˱������� ����: C:\Program Files\Java\android-sdk-windows\platforms\android-27\android.jar(java/lang/String.class): ���汾 52 �� 51 ��, �˱�����֧�����µ����汾�� ���������˱������� ����: C:\Program Files\Java\android-sdk-windows\platforms\android-27\android.jar(java/lang/AutoCloseable.class): ���汾 52 �� 51 ��, �˱�����֧�����µ����汾�� ���������˱������� 3 ������ (包含ID,名称,描述等)和artist(多对多关系),包含event_artistartist_id列。

event_id

这会返回重复的ID,这是我不想要的。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

您正在寻找一个查询,用于选择在event_artist列中包含行的艺术家行。

在SQL中,可以使用exists

编写
knex

knex('artists as a') .whereExists( knex .select('*') .from('event_artists as ea') .whereRaw('ea.artist_id = a.id') ) 中可以写出

myVar REAL NOT NULL

答案 1 :(得分:0)

这应该是加入而不只是加入 -

return knex('event_artist')
  .leftJoin('artist', 'event_artist.artist_id', 'artist.id')
  .offset(offset)
  .limit(howMany)