what wrong with mysql statement

#1064 - 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 '*) from member, amphur Where amphur.AMPHUR_CODE = substring(member.own,3,4) g' at line 1
select   substring(member.own,3,4),  count (*)
 from member, amphur 
Where amphur.AMPHUR_CODE  = substring(member.own,3,4)
group by substring(member.own,3,4)

Open in new window

teeraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tigin44Commented:
try this


select   substring(member.`own`,3,4),  count (*)
 from member
 inner join  amphur on amphur.AMPHUR_CODE  = substring(member.`own`,3,4)
group by substring(member.`own`,3,4)
0
jimyXCommented:
I am not sure but let's try this one please:
select  substring(member.own,3,4) as Col1,  count (*) as Col2
 from member, amphur
Where amphur.AMPHUR_CODE  = substring(member.own,3,4)
group by Col1
0
teeraAuthor Commented:
select   substring(member.own,3,4),  count(*),amphur.AMPHUR_NAME
 from member, amphur
Where amphur.AMPHUR_CODE  = substring(member.own,3,4)
group by substring(member.own,3,4)


#1267 - Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
0
teeraAuthor Commented:
CREATE TABLE IF NOT EXISTS `member` (
  `idmember` int(11) NOT NULL AUTO_INCREMENT,
  `own` varchar(255) DEFAULT NULL,
  `Sname` varchar(255) DEFAULT NULL,
  `Ssurname` varchar(255) DEFAULT NULL,
  `Sex` enum('¿','¿') NOT NULL,
  `Hno` varchar(255) DEFAULT NULL,
  `Moo` varchar(255) DEFAULT NULL,
  `tambol` varchar(200) NOT NULL,
  `dateofbirth` date DEFAULT NULL,
  `migratedate` date DEFAULT NULL,
  `status` enum('5','4','3','2','1') DEFAULT '5',
  `Unit` int(4) DEFAULT NULL,
  `staff1` int(11) DEFAULT NULL,
  `staff2` int(11) DEFAULT NULL,
  `fathercode` varchar(30) NOT NULL,
  `mathercode` varchar(30) NOT NULL,
  PRIMARY KEY (`idmember`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=8994 ;


CREATE TABLE IF NOT EXISTS `amphur` (
  `AMPHUR_ID` int(5) NOT NULL AUTO_INCREMENT,
  `AMPHUR_CODE` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `AMPHUR_NAME` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
  `GEO_ID` int(5) NOT NULL DEFAULT '0',
  `PROVINCE_ID` int(5) NOT NULL DEFAULT '0',
  `province_name` varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`AMPHUR_ID`),
  KEY `province_name` (`province_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=999 ;
0
SharathData EngineerCommented:
try this.
SELECT SUBSTRING(m.own,3,4), 
         COUNT(* ) AS cnt 
    FROM MEMBER AS m, 
         amphur AS a 
   WHERE a.AMPHUR_CODE COLLATE utf8_general_ci = SUBSTRING(m.own,3,4) 
GROUP BY SUBSTRING(m.own,3,4)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.