[Solved] get the total values of different user in mysql and php [closed]

SELECT MIN(a.ID) ID, a.name, SUM(b.Price) Price FROM table1 a INNER JOIN table2 b ON a.PID = b.PID GROUP BY a.Name SQLFiddle Demo OUTPUT ╔════╦══════╦═══════╗ ║ ID ║ NAME ║ PRICE ║ ╠════╬══════╬═══════╣ ║ 1 ║ ram ║ 4333 ║ ║ 2 ║ rani ║ 2000 ║ ╚════╩══════╩═══════╝ solved get the total values of different user … Read more

[Solved] SQL query WHERE string LIKE field [closed]

I think the issue is that you have an extra space after the inserted text in the SQL. This means that you are effectively searching for “lblheader.text ” (with a space after it) everytime, which I doubt is what you want. In the SQL statement , change LIKE ‘%”+ lblheader.Text +” %’ “; To LIKE … Read more

[Solved] Select top 1 from each group sql

Maybe this… get the maximum sum for each city and menu item name. Top returns 1 row not one row per group. you need to use the max aggregate to make this work the way you want. you can’t double aggregate max(sum(Quantity)) so you have to either use a sub select, or use a CTE … Read more

[Solved] PHP Insert Table Data Code not Inserting Data into MSSQL Table [closed]

MSSQL doesn’t have a direct md5 function (you can convert it as demonstrated here). You need to use it through PHP like so: $sqla = “INSERT INTO users (username, password) VALUES (‘rob_dewar01’, ‘” . md5(‘KingDozer’) . “‘)”; Also, md5 is not secure. Look into using prepared statements. See the Secure hash and salt for PHP … Read more

[Solved] SELECT from table with three foregin keys to one table [closed]

Okay, it’s Saturday night and I’m feeling mellow enough to tackle this without a data model. You have given us the names of the three lookup tables (subjects, opinions, users) but not the actual structures and columns. So I’m making some guesses. select subjects.name as subject_name , opinions.value , o_users.name as opinion_guy , p_users.name as … Read more

[Solved] Display the job title concatenated with the max salary (separated by a : and space) and name the column “Job Salary Range”. Use concat function

Display the job title concatenated with the max salary (separated by a : and space) and name the column “Job Salary Range”. Use concat function solved Display the job title concatenated with the max salary (separated by a : and space) and name the column “Job Salary Range”. Use concat function

[Solved] SQL Multiple request

Try this instead: $result = doQuery(“SELECT DISTINCT c.PkID, c.CategoryName FROM ” . HC_TblPrefix . “categories c WHERE c.IsActive = 1 AND c.PkID IN (‘”. implode(“‘, ‘”, explode(“,”, $catIDs)) .”‘) ORDER BY c.CategoryName”); The reason your loop is only returning the last result is because you overwrite $resultCat every time, so when your loop is done, … Read more

[Solved] Why does try catch not catch Sql syntax error

The catch in the above code does actually catch the exception. On the exception set the Select Command to something default that is sure to work ie. SELECT * FROM Database And Execute the select. The reason for this is when the page does a post back it tries to execute the select statement that … Read more

[Solved] How do I convert this Access Query to mySQL query

The query works in MySQL when the statement is as generated by Access iteself. No change required. Here is the answer below: FROM qryvw_employees INNER JOIN (tbl_clients INNER JOIN tbl_assignments ON tbl_clients.`PAN` = tbl_assignments.`PAN` INNER JOIN tbl_tasks ON tbl_assignments.`Assignment_ID` = tbl_tasks.`Assignment_ID` INNER JOIN qryvw_subtasks ON tbl_tasks.`TaskID` = qryvw_subtasks.`TaskID`) ON qryvw_employees.`ID` = tbl_tasks.`Assigned_To` solved How do … Read more

[Solved] Display the different salary figures earned by faculty members arranged in descending order [closed]

As I understand it you want to have a list of unique salary values in descending order. This is how you can achieve it: SELECT Salary FROM faculty group by Salary order by Salary desc Alternative: SELECT distinct(Salary) FROM faculty order by Salary desc This will give you all the salaries in descending order. If … Read more