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

Problem arises in a SQL statement

Hi All,

I have a samll problem related to a specific query. It creates following error. Unknown column 'attendance_state.state' in 'field list'

$query="SELECT attendance_state.state,attendance_state.state_id from attendance_state inner join attendance on attendance_state.state_id=attendance.state_id where attendance.admission_no='".$admission_id[$i]."' and attendance.date='$date'";
$result=mysql_query($query) or die (mysql_error());

The table related to the query looks like this. "state_id" is set as auto increment field.

attendance_state (state_id, state)
attendance (admission_no, state_id, date)

4
Contributors
3
Replies
5 Days
Discussion Span
8 Months Ago
Last Updated
4
Views
heshanm
Junior Poster
169 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Show your CREATE TABLE statement.

smantscheff
Nearly a Posting Virtuoso
1,297 posts since Oct 2010
Reputation Points: 321
Solved Threads: 270
Skill Endorsements: 8

Here it is..I have used WAMP and PHPMyAdmin to create database and tables.

CREATE TABLE `attendance_state` (
  `state_id` int(20) NOT NULL auto_increment,
  `state` varchar(20) NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY  (`state_id`)
)
heshanm
Junior Poster
169 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

same query works here fine

urtrivedi
Posting Virtuoso
1,714 posts since Dec 2008
Reputation Points: 299
Solved Threads: 362
Skill Endorsements: 24

This article has been dead for over three months: Start a new discussion instead

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