Jump to content

Inner Join and String issue


wwyatt

Recommended Posts

My current MySQL version is 5.0

 

The statement I'm trying to run is below....

 

SELECT projectwork.Date, projectwork.ProjectTitle, projectwork.Hours, projectwork.Consultant, projectwork.Type, isccmasterlist.LastName, isccmasterlist.FirstName

FROM projectwork

JOIN isccmasterlist

ON projectwork.ISCCID=isccmasterlist.ISCCID

WHERE YEAR(projectwork.Date) = 2009 AND MONTH(projectwork.Date) = 01 AND STRCMP(projectwork.Consultant,'BW')=0

 

The issue is the last part ... "AND STRCMP(projectwork.Consultant,'BW')=0

 

I've tried one other simpler line ...."AND projectwork.Consultant='BW'

 

As well as every variation on "BW" \'BW\' etc....

 

There error I get is below....

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'BW\')=0 at line 5

 

If I remove the last line it will return all the data from 01/2009. However it will not let me do any sort of string comparison. I always get this error even if I put in a different consultants initials, or try a different string variable. Only numeric variables work.

 

Any help would be appriciated

 

Below is a create tables statement for the entire DB. Only two tables are involved

 

# phpMyAdmin MySQL-Dump

# version 2.2.0

# http://phpwizard.net/phpMyAdmin/

# http://phpmyadmin.sourceforge.net/ (download page)

#

# Host: mysql.iu.edu:3394

# Generation Time: June 7, 2010, 11:51 am

# Server version: 5.00.83

# PHP Version: 4.4.7

# Database : `iscclink`

# --------------------------------------------------------

 

#

# Table structure for table `clientprojects`

#

 

CREATE TABLE clientprojects (

  ProjID int(11) NOT NULL auto_increment,

  ISCCID int(11) NOT NULL,

  Username text NOT NULL,

  LastName text NOT NULL,

  FirstName text NOT NULL,

  StartDate date default NULL,

  ProjectTitle text NOT NULL,

  ProjectDesc text NOT NULL,

  ProjectNotes text NOT NULL,

  ProjectBill text NOT NULL,

  PRIMARY KEY  (ProjID),

  UNIQUE KEY ProjID_2 (ProjID),

  KEY ProjID (ProjID)

) ENGINE=MyISAM AUTO_INCREMENT=872 DEFAULT CHARSET=latin1;

# --------------------------------------------------------

 

#

# Table structure for table `isccmasterlist`

#

 

CREATE TABLE isccmasterlist (

  ISCCID int(11) NOT NULL auto_increment,

  LastName text NOT NULL,

  FirstName text NOT NULL,

  Username text,

  AltEmail text NOT NULL,

  Campus text NOT NULL,

  School text NOT NULL,

  Dept text NOT NULL,

  SchoolDesc text NOT NULL,

  DeptDesc text,

  `Status` text NOT NULL,

  Rank text NOT NULL,

  Notes text NOT NULL,

  PRIMARY KEY  (ISCCID),

  UNIQUE KEY ISCCID_2 (ISCCID),

  KEY ISCCID (ISCCID)

) ENGINE=MyISAM AUTO_INCREMENT=667 DEFAULT CHARSET=latin1;

# --------------------------------------------------------

 

#

# Table structure for table `iumasterlist`

#

 

CREATE TABLE iumasterlist (

  IUID int(11) NOT NULL auto_increment,

  Username text NOT NULL,

  LastName text NOT NULL,

  FirstName text NOT NULL,

  Campus text NOT NULL,

  `Status` text NOT NULL,

  Title text NOT NULL,

  Rank text NOT NULL,

  SchoolCode text NOT NULL,

  DeptCode text NOT NULL,

  SchoolDesc text NOT NULL,

  DeptDesc text,

  PRIMARY KEY  (IUID),

  UNIQUE KEY IUID_2 (IUID),

  KEY IUID (IUID)

) ENGINE=MyISAM AUTO_INCREMENT=36168 DEFAULT CHARSET=latin1;

# --------------------------------------------------------

 

#

# Table structure for table `projectwork`

#

 

CREATE TABLE projectwork (

  WorkID int(11) NOT NULL auto_increment,

  ProjID int(11) NOT NULL,

  ISCCID int(11) NOT NULL,

  Username text NOT NULL,

  LastName text NOT NULL,

  FirstName text NOT NULL,

  ProjectTitle text NOT NULL,

  MeetingID int(11) NOT NULL,

  `Date` date default NULL,

  Consultant text NOT NULL,

  `Type` text NOT NULL,

  Hours decimal(3,2) default NULL,

  WorkBill text NOT NULL,

  WorkNotes text,

  PRIMARY KEY  (WorkID),

  UNIQUE KEY WorkID_2 (WorkID),

  KEY WorkID (WorkID)

) ENGINE=MyISAM AUTO_INCREMENT=2982 DEFAULT CHARSET=latin1;

Link to comment
Share on other sites

First off, Thank you.

 

I've been working on all this syntax in phpMyAdmin 2.2.0 window. I tend to do this first before I waste my time setting it up in PHP. However I went ahead and set up a generic table with this data in it.

 

The PHP code and SQL syntax work.

 

So any idea why the phpMyAdmin is giving me this error?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.