I wan to check that is my sql command containing the inputted data or notHow to check that inputted data is in foreach or not?How to export and import a .sql file from command line with options?SQL query return data from multiple tablesHow do I import an SQL file using the command line in MySQL?mysql left join selecting only highest from left tableSQL using SUM: making two additions in the same statement?Get multiple values from DBWhen combining multiple queries into one how do you sum columns togetherMysql Query maximum records in n*2 formatselect top 5 scores for each teamLaravel input data to multiple tables and validation
Spongy green glass found on graves
Airline power sockets shut down when I plug my computer in. How can I avoid that?
Why was ramjet fuel used as hydraulic fluid during Saturn V checkout?
What should I do with the stock I own if I anticipate there will be a recession?
Is there a utility / method to organize trad gear so that each piece is immediately accessible?
Are there categories whose internal hom is somewhat 'exotic'?
Vegetarian dishes on Russian trains (European part)
Installing the original OS X version onto a Mac?
Why do aircraft leave cruising altitude long before landing just to circle?
Does git delete empty folders?
How can I train a replacement without them knowing?
Peterhead Codes and Ciphers Club: Weekly Challenge
Is there a way to make the "o" keypress of other-window <C-x><C-o> repeatable?
9 hrs long transit in DEL
Shading faces depending on orientation
Would getting a natural 20 with a penalty still count as a critical hit?
Why should I pay for an SSL certificate?
Quick destruction of a helium filled airship?
Reducing contention in thread-safe LruCache
Why should P.I be willing to write strong LOR even if that means losing a undergraduate from his/her lab?
What security risks does exposing the size of the plaintext entail?
When does The Truman Show take place?
Tabularx with hline and overrightarrow vertical spacing
Repurpose telephone line to ethernet
I wan to check that is my sql command containing the inputted data or not
How to check that inputted data is in foreach or not?How to export and import a .sql file from command line with options?SQL query return data from multiple tablesHow do I import an SQL file using the command line in MySQL?mysql left join selecting only highest from left tableSQL using SUM: making two additions in the same statement?Get multiple values from DBWhen combining multiple queries into one how do you sum columns togetherMysql Query maximum records in n*2 formatselect top 5 scores for each teamLaravel input data to multiple tables and validation
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have two rounds "first and knock-out".Only the 4 team can go to knock-out round if they got the highest point on first round. Now firstly, I want to select that 4 team from first round and then check whether the inputted team is on the selected 4 team or not. Take a look to my code(So far i tried)
[In this image the two teams are marked should be exclude but when i giving condition it doesn't exclude those two teams]

$matches= new Match();
$matches->team1 = $request->input('team1');
$matches->team2 = $request->input('team2');
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4');
if($ko == $matches->team1 || $ko == $matches->team2)
$matches->round = "ko";
else
$matches->round = "first";
Screenshot of $kos after update.
mysql laravel laravel-5
add a comment |
I have two rounds "first and knock-out".Only the 4 team can go to knock-out round if they got the highest point on first round. Now firstly, I want to select that 4 team from first round and then check whether the inputted team is on the selected 4 team or not. Take a look to my code(So far i tried)
[In this image the two teams are marked should be exclude but when i giving condition it doesn't exclude those two teams]

$matches= new Match();
$matches->team1 = $request->input('team1');
$matches->team2 = $request->input('team2');
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4');
if($ko == $matches->team1 || $ko == $matches->team2)
$matches->round = "ko";
else
$matches->round = "first";
Screenshot of $kos after update.
mysql laravel laravel-5
add a comment |
I have two rounds "first and knock-out".Only the 4 team can go to knock-out round if they got the highest point on first round. Now firstly, I want to select that 4 team from first round and then check whether the inputted team is on the selected 4 team or not. Take a look to my code(So far i tried)
[In this image the two teams are marked should be exclude but when i giving condition it doesn't exclude those two teams]

$matches= new Match();
$matches->team1 = $request->input('team1');
$matches->team2 = $request->input('team2');
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4');
if($ko == $matches->team1 || $ko == $matches->team2)
$matches->round = "ko";
else
$matches->round = "first";
Screenshot of $kos after update.
mysql laravel laravel-5
I have two rounds "first and knock-out".Only the 4 team can go to knock-out round if they got the highest point on first round. Now firstly, I want to select that 4 team from first round and then check whether the inputted team is on the selected 4 team or not. Take a look to my code(So far i tried)
[In this image the two teams are marked should be exclude but when i giving condition it doesn't exclude those two teams]

$matches= new Match();
$matches->team1 = $request->input('team1');
$matches->team2 = $request->input('team2');
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4');
if($ko == $matches->team1 || $ko == $matches->team2)
$matches->round = "ko";
else
$matches->round = "first";
Screenshot of $kos after update.
mysql laravel laravel-5
mysql laravel laravel-5
edited Mar 27 at 15:08
Tim Lewis
13.1k8 gold badges41 silver badges71 bronze badges
13.1k8 gold badges41 silver badges71 bronze badges
asked Mar 27 at 13:44
Tanvir AhmedTanvir Ahmed
286 bronze badges
286 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
First of all, $ko doesn't contain the results of the query until you pass it a closure, in this case ->first().
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4')->first();
Next, you need to compare the value of $ko->team to $matches->team1 or $matches->team2:
if($ko->team == $matches->team1 || $ko->team == $matches->team2)
...
Lastly, some clean up. The DB query can be simplified to use Eloquent syntax, instead of a raw SELECT:
$ko = DB::table("points")
->where("round", "=", "first")
->orderBy("points", "DESC")
->orderBy("run_rate", "DESC")
// ->limit(4) // Removing this; incompatible with `->first()`
->first();
There's another logic error; if you need to limit(4), then you can't use ->first(), you'd have to use ->get(), which then creates a Collection, which can't be compared to $matches unless you loop:
$kos = DB::table("points")...->get();
$matches->round = "first";
foreach($kos AS $ko)
if($ko->team == $matches->team1
All in all, you need to reexamine what you're trying to do and read up on the Eloquent syntax, how to execute queries and return results, how to loop, access properties and compare those results, etc.
Edit: Since you're looping and comparing, set the default value of $matches->round to "first", then, while looping, if the compare condition is true, override $matches->round to "ko" and break out of the loop.
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Can you run add($ko)and tell me what it contains? (Edit the original question with that content please)
– Tim Lewis
Mar 27 at 14:57
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
|
show 7 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378744%2fi-wan-to-check-that-is-my-sql-command-containing-the-inputted-data-or-not%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First of all, $ko doesn't contain the results of the query until you pass it a closure, in this case ->first().
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4')->first();
Next, you need to compare the value of $ko->team to $matches->team1 or $matches->team2:
if($ko->team == $matches->team1 || $ko->team == $matches->team2)
...
Lastly, some clean up. The DB query can be simplified to use Eloquent syntax, instead of a raw SELECT:
$ko = DB::table("points")
->where("round", "=", "first")
->orderBy("points", "DESC")
->orderBy("run_rate", "DESC")
// ->limit(4) // Removing this; incompatible with `->first()`
->first();
There's another logic error; if you need to limit(4), then you can't use ->first(), you'd have to use ->get(), which then creates a Collection, which can't be compared to $matches unless you loop:
$kos = DB::table("points")...->get();
$matches->round = "first";
foreach($kos AS $ko)
if($ko->team == $matches->team1
All in all, you need to reexamine what you're trying to do and read up on the Eloquent syntax, how to execute queries and return results, how to loop, access properties and compare those results, etc.
Edit: Since you're looping and comparing, set the default value of $matches->round to "first", then, while looping, if the compare condition is true, override $matches->round to "ko" and break out of the loop.
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Can you run add($ko)and tell me what it contains? (Edit the original question with that content please)
– Tim Lewis
Mar 27 at 14:57
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
|
show 7 more comments
First of all, $ko doesn't contain the results of the query until you pass it a closure, in this case ->first().
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4')->first();
Next, you need to compare the value of $ko->team to $matches->team1 or $matches->team2:
if($ko->team == $matches->team1 || $ko->team == $matches->team2)
...
Lastly, some clean up. The DB query can be simplified to use Eloquent syntax, instead of a raw SELECT:
$ko = DB::table("points")
->where("round", "=", "first")
->orderBy("points", "DESC")
->orderBy("run_rate", "DESC")
// ->limit(4) // Removing this; incompatible with `->first()`
->first();
There's another logic error; if you need to limit(4), then you can't use ->first(), you'd have to use ->get(), which then creates a Collection, which can't be compared to $matches unless you loop:
$kos = DB::table("points")...->get();
$matches->round = "first";
foreach($kos AS $ko)
if($ko->team == $matches->team1
All in all, you need to reexamine what you're trying to do and read up on the Eloquent syntax, how to execute queries and return results, how to loop, access properties and compare those results, etc.
Edit: Since you're looping and comparing, set the default value of $matches->round to "first", then, while looping, if the compare condition is true, override $matches->round to "ko" and break out of the loop.
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Can you run add($ko)and tell me what it contains? (Edit the original question with that content please)
– Tim Lewis
Mar 27 at 14:57
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
|
show 7 more comments
First of all, $ko doesn't contain the results of the query until you pass it a closure, in this case ->first().
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4')->first();
Next, you need to compare the value of $ko->team to $matches->team1 or $matches->team2:
if($ko->team == $matches->team1 || $ko->team == $matches->team2)
...
Lastly, some clean up. The DB query can be simplified to use Eloquent syntax, instead of a raw SELECT:
$ko = DB::table("points")
->where("round", "=", "first")
->orderBy("points", "DESC")
->orderBy("run_rate", "DESC")
// ->limit(4) // Removing this; incompatible with `->first()`
->first();
There's another logic error; if you need to limit(4), then you can't use ->first(), you'd have to use ->get(), which then creates a Collection, which can't be compared to $matches unless you loop:
$kos = DB::table("points")...->get();
$matches->round = "first";
foreach($kos AS $ko)
if($ko->team == $matches->team1
All in all, you need to reexamine what you're trying to do and read up on the Eloquent syntax, how to execute queries and return results, how to loop, access properties and compare those results, etc.
Edit: Since you're looping and comparing, set the default value of $matches->round to "first", then, while looping, if the compare condition is true, override $matches->round to "ko" and break out of the loop.
First of all, $ko doesn't contain the results of the query until you pass it a closure, in this case ->first().
$ko = DB::select('SELECT * FROM points WHERE round="first" ORDER BY points DESC , run_rate DESC LIMIT 4')->first();
Next, you need to compare the value of $ko->team to $matches->team1 or $matches->team2:
if($ko->team == $matches->team1 || $ko->team == $matches->team2)
...
Lastly, some clean up. The DB query can be simplified to use Eloquent syntax, instead of a raw SELECT:
$ko = DB::table("points")
->where("round", "=", "first")
->orderBy("points", "DESC")
->orderBy("run_rate", "DESC")
// ->limit(4) // Removing this; incompatible with `->first()`
->first();
There's another logic error; if you need to limit(4), then you can't use ->first(), you'd have to use ->get(), which then creates a Collection, which can't be compared to $matches unless you loop:
$kos = DB::table("points")...->get();
$matches->round = "first";
foreach($kos AS $ko)
if($ko->team == $matches->team1
All in all, you need to reexamine what you're trying to do and read up on the Eloquent syntax, how to execute queries and return results, how to loop, access properties and compare those results, etc.
Edit: Since you're looping and comparing, set the default value of $matches->round to "first", then, while looping, if the compare condition is true, override $matches->round to "ko" and break out of the loop.
edited Mar 27 at 15:05
answered Mar 27 at 14:18
Tim LewisTim Lewis
13.1k8 gold badges41 silver badges71 bronze badges
13.1k8 gold badges41 silver badges71 bronze badges
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Can you run add($ko)and tell me what it contains? (Edit the original question with that content please)
– Tim Lewis
Mar 27 at 14:57
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
|
show 7 more comments
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Can you run add($ko)and tell me what it contains? (Edit the original question with that content please)
– Tim Lewis
Mar 27 at 14:57
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Thank you @Tim Lewis for you time, but when my in put is "$matches->team1=Barisal" and "$matches->team2=Rajshahi" then $matches->round shoul be "ko" but it save as "first"
– Tanvir Ahmed
Mar 27 at 14:56
Can you run a
dd($ko) and tell me what it contains? (Edit the original question with that content please)– Tim Lewis
Mar 27 at 14:57
Can you run a
dd($ko) and tell me what it contains? (Edit the original question with that content please)– Tim Lewis
Mar 27 at 14:57
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Heres what i get after dd($kos)
– Tanvir Ahmed
Mar 27 at 15:00
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
Ok, I see it now. I'll add an update.
– Tim Lewis
Mar 27 at 15:03
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
i give the dd($kos) screenshot ..can you check that please..
– Tanvir Ahmed
Mar 27 at 15:04
|
show 7 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378744%2fi-wan-to-check-that-is-my-sql-command-containing-the-inputted-data-or-not%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown