-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Cumulative sum in MySQL View (calculating running profit/loss)
Barand replied to DariusB's topic in MySQL Help
I added "match_id" from your mecze table to your current "cumulative_profit" view then ran my query against that view instead of the mecze table. You have already done the hard work to calculate the profit in that view. SELECT country ,Competition ,match_date ,ko_time ,home ,away ,Result ,Profit ,cum_profit FROM cumulative_profit INNER JOIN ( SELECT match_id , @cum:=@cum+profit as cum_profit FROM cumulative_profit JOIN (SELECT @cum:=0) init ORDER BY ko_time, match_id ) cum USING (match_id) ORDER BY ko_time DESC, match_id DESC; results +---------+----------------+------------+---------+-------------------+--------------+--------+--------+------------+ | country | competition | match_date | ko_time | home | away | Result | Profit | cum_profit | +---------+----------------+------------+---------+-------------------+--------------+--------+--------+------------+ | England | Premier League | 2015-11-07 | 15:00 | Leicester | Watford | W | 8.70 | -20.28 | | England | Premier League | 2015-11-07 | 15:00 | West Ham | Everton | L | -10 | -28.98 | | England | Championship | 2015-11-02 | 15:00 | Bolton | BristolCity | L | -10 | -18.98 | | England | Championship | 2015-11-05 | 15:00 | Blackburn | Brentford | W | 8.82 | -8.98 | | England | Premier League | 2015-11-07 | 15:00 | Manchester United | West Brom | L | -10 | -17.8 | | England | Premier League | 2015-11-07 | 15:00 | Norwich | Swansea | L | -10 | -7.8 | | England | Premier League | 2015-11-07 | 15:00 | Sunderland | Southampton | L | -10 | 2.2 | | England | Championship | 2015-11-06 | 12:30 | Huddersfield | Leeds | W | 12.20 | 12.2 | +---------+----------------+------------+---------+-------------------+--------------+--------+--------+------------+ -
What if you select "childrenID" instead of "signupChildrenID"? Or SELECT * FROM activities LEFT JOIN signupActivity ON activityID = SignupActivityID AND signupActivitychildID = 33 LEFT JOIN children ON signupActivitychildID = childrenID WHERE activitySection = 3
-
how to cross post when target site has no open API endpoint?
Barand replied to sasori's topic in PHP Coding Help
I suspect the real question is "How can I bombard sites with spam?" -
In that output you want the scores, which can all be different. If you only show the form once, which of those different scores would you show? Also, in that output, it shows repeating values for position and evaluator. As your opening post says you don't want these repeating then the question still remains - what do you want the output to look like?
-
You show two different outputs. Which one do you want? Or do you want a third version and, if so, what? What is your database structure?
-
Because you are LEFT JOINing to signup and children tables you cannot put selection conditions on those tables in a WHERE clause. If you do then the LEFT JOINS will behave like INNER JOINS. You need to put those criteria in the ON clauses for the joins, SELECT * FROM activities LEFT JOIN signupActivity ON activityID = SignupActivityID LEFT JOIN children ON signupActivitychildID = childrenID AND childrenID = 33 WHERE activitySection = 3 (DON'T use SELECT *, specify just those columns you need)
-
Cumulative sum in MySQL View (calculating running profit/loss)
Barand replied to DariusB's topic in MySQL Help
Well, you've certainly moved the goal posts since your original post on which my solution was based. Provide an SQL data dump of the necessary table, so I don't waste more of my time setting up test data, and I will look at it again for you. -
Cumulative sum in MySQL View (calculating running profit/loss)
Barand replied to DariusB's topic in MySQL Help
If there's no id field, what is the primary key on that table? -
Somewhere you need a table which would tell the query that 30 books were available for item_id 8 if you want to know how many you can loan
-
Cumulative sum in MySQL View (calculating running profit/loss)
Barand replied to DariusB's topic in MySQL Help
Mine relied on each row in mecze table having a unique "id" column. My output is copy/pasted from mysql command line -
try SELECT mot , COUNT(*) as nmbr , GROUP_CONCAT(pseudo ORDER BY pseudo SEPARATOR ', ') as players FROM unanimo GROUP BY mot HAVING nmbr > 1 ORDER BY nmbr DESC; +--------+------+-------------------+ | mot | nmbr | players | +--------+------+-------------------+ | beetle | 3 | Mary, Paul, Peter | | spider | 3 | Mary, Paul, Peter | | animal | 3 | Mary, Paul, Peter | | bird | 2 | Mary, Paul | | bug | 2 | Mary, Peter | | cow | 2 | Mary, Paul | | dog | 2 | Mary, Paul | +--------+------+-------------------+
-
Cumulative sum in MySQL View (calculating running profit/loss)
Barand replied to DariusB's topic in MySQL Help
try SELECT country ,Competition ,match_date ,ko_time ,home ,away ,Result ,Profit ,cum_profit FROM mecze INNER JOIN ( SELECT id , @cum:=@cum+profit as cum_profit FROM mecze JOIN (SELECT @cum:=0) init ORDER BY ko_time, id ) cum USING (id) ORDER BY ko_time DESC, id DESC; +---------+----------------+------------+----------+--------+--------------+--------+--------+------------+ | country | Competition | match_date | ko_time | home | away | Result | Profit | cum_profit | +---------+----------------+------------+----------+--------+--------------+--------+--------+------------+ | Europe | Europa League | 2015-11-05 | 20:05:00 | Sparta | Schalke | L | -10 | -12 | | Denmark | Superliga | 2015-11-05 | 18:00:00 | Aarhus | Sonderjyske | L | -10 | -2 | | Europe | Europa League | 2015-11-05 | 18:00:00 | Plzen | Rapid Vienna | W | 10 | 8 | | Europe | Europa League | 2015-11-05 | 18:00:00 | Celtic | Molde | W | 8 | -2 | | Bahrain | Premier League | 2015-11-05 | 15:00:00 | Manama | East Riffa | L | -10 | -10 | +---------+----------------+------------+----------+--------+--------------+--------+--------+------------+ -
this query should calculate the scores for you SELECT pseudo , SUM(nmbr) as score FROM unanimo INNER JOIN ( SELECT mot , COUNT(*) as nmbr FROM unanimo GROUP BY mot HAVING nmbr > 1 ) tot USING (mot) GROUP BY pseudo ORDER BY score DESC; Data and results
-
Use password_hash() and password_verify(). http://php.net/manual/en/function.password-hash.php (You may find the notes on that page useful if you are not yet on PHP5.5+)
-
Yes. But unlink() is a function, not a variable.
-
Is it something simple like that page is missing the session_start() call at the beginning of the script?
-
Don't put FiscalYear condition in the WHERE clause, put it in the table join condition LEFT JOIN eventtbl e ON c.cid = e.cid AND e.FiscalYear = 'FY16'
-
BTW, "dog"=<"Image/Dog.jpg" should be "dog"=>"Image/Dog.jpg"
-
Skip first line on import csv using php mysqli
Barand replied to samuel_lopez's topic in PHP Coding Help
You could check if the age value is numeric. If it isn't (header), skip the insert. -
Exclude dates that you don't want to display in the original query. Don't select them then hide them.
-
You said that "CNT_TXT_WARNING_EMAILSENTOK" is defined in a text file. How do you get it from said text file to that script?
-
Can php do two execute (queries) in same time?
Barand replied to sigmahokies's topic in PHP Coding Help
It worked well enough for me to produce that output. You may have to make one or two minor tweaks to adapt it to your database and table. -
Can php do two execute (queries) in same time?
Barand replied to sigmahokies's topic in PHP Coding Help
I already gave you the code that produced that output. How much more help do you need? -
Can php do two execute (queries) in same time?
Barand replied to sigmahokies's topic in PHP Coding Help
-
Do have CNT_TXT_WARNING_EMAILSENTOK defined anywhere, for example define("CNT_TXT_WARNING_EMAILSENTOK", "This is a message to say it is OK");