Thursday, January 20, 2022

[FIXED] SQL code not going through in phpmyadmin

Issue

I entered the following SQL code into phpmyadmin:

i1: display inventory rows for apple
list the quantity total for apple

select fruitID, sum( quantity ) from inventory
where fruitID=
(select fruitID from fruit where name = “apple”);

I am getting the error message:

unknown column "apple"

and it is not going through. What is wrong with this code?


Solution

You are using and . You should use the usual quotation marks " which are used to identify string literals correctly.

Try it again with the usual quotation marks:

SELECT fruitID, sum( quantity ) 
FROM inventory 
WHERE fruitID= 
    (SELECT fruitID 
    FROM fruit 
    WHERE name = "apple");


Answered By - Ibrahim Mohamed

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.