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;








1















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]



enter image description here



$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.
enter image description here










share|improve this question
































    1















    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]



    enter image description here



    $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.
    enter image description here










    share|improve this question




























      1












      1








      1








      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]



      enter image description here



      $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.
      enter image description here










      share|improve this question
















      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]



      enter image description here



      $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.
      enter image description here







      mysql laravel laravel-5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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

























          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer



























          • 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











          • 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










          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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.






          share|improve this answer



























          • 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











          • 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















          0














          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.






          share|improve this answer



























          • 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











          • 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













          0












          0








          0







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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 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











          • 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











          • 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











          • 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








          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.



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

          밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

          1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴