76006

MySQL WHERE-condition in procedure ignored

I am trying to make a procedure with arguments. But when I use them in a WHERE condition it is like there were never there. They are simply ignored.

DELIMITER // DROP PROCEDURE IF EXISTS p // CREATE PROCEDURE p (IN player TEXT, OUT num INT) BEGIN SELECT COUNT(*) INTO num FROM `sg_playerstats` WHERE `player` = player; END // DELIMITER ;

Num gets filled correctly, but whatever I put in player, the result is ALWAYS 66. (The table has 66 rows!)

What am I doing wrong???

Answer1:

rename your parameter,

CREATE PROCEDURE p (IN _player TEXT, OUT num INT) BEGIN SELECT COUNT(*) INTO num FROM `sg_playerstats` WHERE `player` = _player; END

the reason why you are getting that is because it happens to have name collision.

Recommend

  • How to check a string does not start with a number in Batch?
  • Exporting SAS DataSet on to UNIX as a text file…with delimiter '~|~'
  • Fraction length
  • Does the MySQL IN clause execute the subquery multiple times?
  • How dotnet build chooses the output name
  • Is there any way to call saveCurrentTurnWithMatchData without sending a push notification?
  • .NET video play library which allows to change the playback rate?
  • Cannot save model when using ember render helper
  • HTML5 video only works in IE. The other browsers shows the black screen
  • hide missing dates from x-axis ggplot2
  • Add dynamic data to line chart from mysql database with highcharts
  • Using Sax parsing to edit and write XML in VB6
  • std::remove_copy_if_ valgrind bytes in block are possibly lost in loss record
  • presentShareDialogWithParams posts to FB wall, but callback handler results say error
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Groovy: Unexpected token “:”
  • How to write order and limit within cakephp joins array
  • How to create a file in java without a extension
  • Django: Count of Group Elements
  • Illegal mix of collations for operation for date/time comparison
  • Sending data from AppleScript to FileMaker records
  • Validaiting emails with Net.Mail MailAddress
  • Adding custom controls to a full screen movie
  • ORA-29908: missing primary invocation for ancillary operator
  • Web-crawler for facebook in python
  • Do I've to free mysql result after storing it?
  • How to get next/previous record number?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Comma separated Values
  • trying to dynamically update Highchart column chart but series undefined
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • How do you join a server to an Active Directory (domain)?
  • how does django model after text[] in postgresql [duplicate]
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How does Linux kernel interrupt the application?
  • Sorting a 2D array using the second column C++
  • java string with new operator and a literal
  • playing video using jmf