Tag: mysql

mysql error inner join

SELECT bp.project_id, bp.project_name, bp.project_costing, bp.project_borrower_id, bp.member_userid, bp.project_staus, SUM(pb.payment_amount) as total FROM borrower_project_master as bp INNER JOIN payment_invest_master as pb ON bp.project_borrower_id=pb.payment_borrowerid WHERE ( (SUM(pb.payment_amount)/bp.project_costing)*100 < 100 AND bp.project_staus=’Y’ ) ORDER BY RAND() LIMIT 0,3 this query show the error Invalid use of group function. Can you help me to solve this problem

Pass value from query 1 to query 2

I have a query join 2 table as below: SELECT * FROM Staff s INNER JOIN Account a on s.AccNo = a.AccNo WHERE a.Status = ‘Active’ The result as shown: AccNo | Name | ID —————— 1 | Alex | S01 2 | John | S02 After I get the staff ID,I write second query […]

Does PDO handle sql functions?

Would PDO be able to handle MySQL functions when interfacing a SQL Server (Microsoft)? For example would PDO convert “SELECT MYSQL-FUNCTION(col1) FROM tbl” where in such a use case MYSQL-FUNCTION only exists in SQL Server as SQLSERVER-FUNCTION?

SQL issue: Inserting values into one clumn, same amount of EMPTY values in every other column

I’ve tried searching a resolution for my issue below, however, results come back with “HOW” to insert null values to a column, which is what I’m trying to prevent. Please educate me. When I insert values into ONE column, every other column gets the same amount of records added, but they are EMPTY!! What?!?!? INSERT […]

MySql Basic table creation/handing

I’m trying to create a simple table where I insert field and I do some checks in MySql. I’ve used Microsoft SQL relatively easy. Instead, MySql give evrrytime query errors without even specifying what’s going on. Poor MySql software design apart, here’s what I’m trying to do: 1 table with 4 fields with an autoincremental […]

Slow performance in linked server query

I’m using a Linked Server Query from MSSQL to mySql. MySql table to be queried has 800K + records I’m using a temp table to pull the results from linked server and do a join on that temp table for SQL query Is there a performance difference between: Declare @MyString varchar(max), @Address varchar(20), @tempTable (Address, […]

How to JOIN on my Result Set and a Third Table?

I’m trying to figure out how to perform a JOIN where I return all the records from my Result set (query 1) below where a.ssan = c.ssn: Query 1: SELECT a.memno, a.name, a.addr1, a.addr2, a.city, a.state, a.zip, a.sex, a.lname, a.ssan, b.addr1 as old_addr1, b.addr2 as old_addr2, b.city as old_city, b.state as old_state, b.zip as old_zip, […]

Update different columns in a stored procedure

I’m trying to port over a concept that I use in Java code that I’ve used to SQL stored procedures and I’m not sure if it’s possible. Essentially, if I have a table with 10 columns I want to be able to update different combinations of columns from the same stored procedure each time. I.e. […]

UPDATE…FROM in MySQL

I have come to know that MySQL doesn’t support UPDATE…FROM. What’s the alternative to that? Actually I am trying to convert a MS-SQL Server Stored procedure to MySQL Stored procedure, and I am stuck at this line where it does: UPDATE LedgerTbl SET RunninTotal = RTotal = RunningTotal + (DEBIT-CREDIT) FROM LedgerTbl; Here is the […]

multi case selection in a stored procedure

SELECT image_id, CASE image_id WHEN 0 THEN (SELECT image_path FROM images WHERE image_id IN (SELECT default_image FROM registration WHERE reg_id IN (SELECT favorite_id FROM @favDT))) ELSE (SELECT image_path FROM images WHERE image_id = b.image_id AND active = 1) END AS image_path FROM buddies b WHERE reg_id IN (SELECT favorite_id FROM @favDT) i’m facing a problem […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.