Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Salut,j'ai essaye la requete d'insertion dans la table avec PHPmyAdmin mais ca m'affiche cette erreur:
#1242 - Subquery returns more than 1 row

Et pourtant je ne vois pas le probleme en tant que debutant

What I have tried:

J'ai essaye avec cette requete SQL:
INSERT INTO comptes(intituleCompte,deviseCompte,dateCreationCompte,banques_idBanques,
                    configcompte_idConfigCompte,personnes_idPersonnes)
                    VALUES('SOLIDALITE','BIF','2020/02/12',(SELECT idBanques FROM banques WHERE sigleBanque='BCB'),(SELECT idConfigComptes FROM configComptes WHERE typeCompte='credit'),(SELECT idPersonnes FROM personnes WHERE CNI='531.1005/186.116'));
Posted
Updated 11-Feb-22 23:31pm

1 solution

The error is pretty clear, even if you translate it into French.
Your subquery returns more than one row. Specifically, this part of your SQL:
SELECT idBanques FROM banques WHERE sigleBanque='BCB'
Or this:
SELECT idConfigComptes FROM configComptes WHERE typeCompte='credit'
Or this:
SELECT idPersonnes FROM personnes WHERE CNI='531.1005/186.116'

If any of those return two rows, SQL has no idea which to INSERT into your new row in the comptes table and so it throws an error rather than risk inserting the wrong data.

At a guess, you need a join of some form, but since we have no idea of your tables and the relationships between them, or what data you are trying to insert we can;t help you any further.

Start by looking at your tables and what they contain. We can't do that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900