你好朋友,我正在尝试在laravel中获取数据,但出现错误SQLSTATE [42S22]:找不到列:1054“ where子句”中的未知列“ users.id”(SQL:选择publications
。*,education
。research_area
来自education
上的publications
内部联接education
。user_id
= publications
。{{1} },其中user_id
。users
= 5)。请帮忙。
我的控制器已给定。
id
答案 0 :(得分:0)
users
表未出现在查询中。大概您应该参考publications.user_id
列:
$data['data'] = DB::table('education')
->join('publications', 'education.user_id', '=', 'publications.user_id')
->select('publications.*', 'education.research_area')
->where('publications.user_id', $user_id)
->get();
答案 1 :(得分:0)
DB::table('education') ->join('publications', 'education.user_id', '=', 'publications.user_id')->select('publications.*','education.research_area') ->where('users.id',$user_id)
->get();
如果您在user_id
表中有列education
。然后只需使用->where('user_id',$user_id)
代替->where('users.id',$user_id)
答案 2 :(得分:0)
请选中此link
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.sanket.mychat"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies
{
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
}
但是您必须更改数据库结构,因为 publications 和 education 表之间没有连接。从您的数据库结构中,每个用户可以拥有许多出版物和许多教育,因此哪个出版物具有哪个教育是问题?