我有两个选择声明
1
select Start_Date
from table1 where Start_Date not in (
select End_Date
from table1)
Run Code Online (Sandbox Code Playgroud)
2
select End_Date from table1
where End_Date not in (
select Start_Date
from table1
)
Run Code Online (Sandbox Code Playgroud)
我想在我使用union时将不同列中的两个select语句组合在一起它给我一个列,其中两个查询的结果我希望每个查询结果在不同的列中,但是当我使用内部联接时
select a.End_Date , b.Start_Date from
( select End_Date from table1
where End_Date not in (
select Start_Date
from table1
) ) a
join
(select Start_Date
from table1 where Start_Date not in (
select End_Date
from table1)
) b
on 1=1
Run Code Online (Sandbox Code Playgroud)
它给我的结果每个记录重复四次帮助我下一步做什么?
我已经定义了与投资组合的用户关系,但它让我的用户模型为null
class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
protected $table = 'users';
protected $fillable = ['name', 'email', 'password'];
protected $hidden = ['password', 'remember_token'];
public function portfolio()
{
$this->hasMany('App\Portfolio');
}
}
Run Code Online (Sandbox Code Playgroud)
我的投资组合模型是
class Portfolio extends Model
{
protected $fillable = ['user_id', 'ptitle', 'pdate','pedate','purl','languages','pdes','attachments'];
public function user()
{
$this->belongsTo('App\User');
}
public function attachments()
{
$this->hasMany('App\Attachment');
}
}
Run Code Online (Sandbox Code Playgroud)
我已经在迁移中定义了外键,我的迁移代码是
public function up()
{
Schema::create('portfolios', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('ptitle');
$table->timestamps();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
}); …Run Code Online (Sandbox Code Playgroud)