我正在为 laravel 的一个学校项目制作一个程序,所以我尝试加入两个表:产品和目的地
表 Product 有以下列:id、name
Destinations 表包含以下列:Destinations:id,product_id,destination,quantity,target_person
我需要加入product_id和id
products = DB::table('products')
->leftJoin('destinations','id','=','destinations.product_id ')
->get();
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用时LEFT JOIN,出现以下错误:
SQLSTATE[23000]:违反完整性约束:1052 on 子句中的列 'id' 不明确(SQL:select * from
productsinner joindestinationsonid=destinations.product_id)
所以基本上,我尝试在我的项目中实现 React Hooks,但它给了我这个错误。也许我是盲人,看不到问题所在,我想我拼错了一些东西。但也许我传递了错误的道具,我现在有点困惑。
这是我的标志是组件:
const SignIn = ({ emailSignInStart, googleSignInStart }) => {
const [userCredentials, setCredentials] = useState({
email: '',
passowrd: ''
});
const { email, password } = userCredentials;
const handleSubmit = async e => {
e.preventDefault();
emailSignInStart(email, password);
};
const handleChange = e => {
const { value, name } = e.target;
setCredentials({ ...userCredentials, [name]: value });
};
return (
<div className='sign-in'>
<h2>I already have an account</h2>
<span>Sign in with your email and passowrd</span>
<form onSubmit={handleSubmit}>
<FormInput
name='email' …Run Code Online (Sandbox Code Playgroud)