I’ve a desk containing some customers’ information:
--------------------------------------------------------------------------
| id | identify | e mail | cellphone | and so forth... |
--------------------------------------------------------------------------
I’ve to retrieve a particular consumer information, after which get his feedback too.
My feedback desk seems like this:
----------------------------------------------------------------
| id | user_id | content material | date |
----------------------------------------------------------------
So I might have two options (I am utilizing mysqli):
--one question answer:
SELECT * FROM `information` LEFT JOIN `feedback` ON `information`.`id`=`user_id` WHERE `information`.`id`=?
--two queries answer:
SELECT * FROM `information` WHERE `id`=?
SELECT * FROM `feedback` WHERE `user_id`=? --I get this from the earlier question
The drawback of the primary question is that I might get arrays like this:
$row1 = ['id'=>1, 'consumer'=>"foo", 'e mail'=>"foo@gmail.com", 'cellphone'=>1234567890, 'id'=>1, 'user_id'=>1, 'content material'=>"I like your web site", 'date'=>"1970-01-01";
$row2 = ['id'=>1, 'consumer'=>"foo", 'e mail'=>"foo@gmail.com", 'cellphone'=>1234567890, 'id'=>2, 'user_id'=>1, 'content material'=>"This text is attention-grabbing", 'date'=>"1970-01-02";
$row3 = ['id'=>1, 'consumer'=>"foo", 'e mail'=>"foo@gmail.com", 'cellphone'=>1234567890, 'id'=>3, 'user_id'=>1, 'content material'=>"I might wish to code such as you", 'date'=>"1970-01-03";
$row4 = ['id'=>1, 'consumer'=>"foo", 'e mail'=>"foo@gmail.com", 'cellphone'=>1234567890, 'id'=>4, 'user_id'=>1, 'content material'=>"I do not know what to jot down", 'date'=>"1970-01-04";
In different phrases, I might get the very same details about the consumer for every remark, and since I solely want the feedback from one individual it will be a waste (?)…
Alternatively, a single question might be sooner than two.
I wouldn’t have sufficient information to make a benchmark, and to be trustworthy I am not even so succesful in it.
So my query is: typically talking (basing in your previous expertise) which answer do you suppose might be sooner?
And sure, this might be learn as a opinion-based query, however I simply hope to get some solutions as goal as attainable, so please wait earlier than flagging it.
Thanks for any response!