We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,371 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

mysql insertion doubt

Dear all,
The first query works while the second doesnt, am not able to figure, can u please help me out.

1) // $query3="insert into ttrough(am,pm) select ttam.subject,ttpm.subjectpm from ttam,ttpm where ttam.class != ttpm.classpm limit 1";// this one actually takes two columns from different tables and checks whether they are not similar(if i may be correct)

2) this encouraged me to try for 4 columns from 4 different table as i needed in my college project.
//$result7=mysql_query("INSERT INTO ttrough(am,am1,pm,pm1) SELECT ttam.subject,ttam1.subject,ttpm.subjectpm,ttpm1.subjectpm WHERE ttam.class!=ttam1.class!=ttpm.classpm!=ttpm1.classpm ");

where , ttrough,ttam,ttam1,ttpm,ttpm2 are different tables

2
Contributors
2
Replies
23 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
seemeamal
Newbie Poster
6 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This part is incorrect

ttam.class != ttam1.class!=ttpm.classpm!=ttpm1.classpm

You can't string them together like that. You need to separate them out as separate claues and use AND or OR to build up the logical expression.

ttam.class!=ttam1.class AND ttam1.class != ttpm.classpm AND ttpm.classpm != ttpm1.classpm
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9

This part is incorrect

ttam.class != ttam1.class!=ttpm.classpm!=ttpm1.classpm

You can't string them together like that. You need to separate them out as separate claues and use AND or OR to build up the logical expression.

ttam.class!=ttam1.class AND ttam1.class != ttpm.classpm AND ttpm.classpm != ttpm1.classpm

its because of people like u that its more easier to learn:)
thank u:)

seemeamal
Newbie Poster
6 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by hericles

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0634 seconds using 2.66MB