开发者

trying to get the money members from table

I have

member table

member_Id
Last name
first name
postcode
reference

another table memberstomships

member_Id
membertomship_lastdate
membertomship_paymentmethod  column with values money  
member_id
membershipstatusid
membershipoptionid

another table membershipstatustype table

membershipstatusid
memberstatustype_name

another table membershiptype

membershiptype_id
membershiptype_name

anot开发者_如何学Goher table membershipoption

membershiptype_id
membershipoptionid

I want to get the lastname and firstname and memberstatustype_name and membershiptype_name and membertomship_lastdate for members those who have membertomship_paymentmethod is money

can any one help me out pls....

many thanks.


Do it yourself! here are the tutorials on how to use SQL joins:

http://w3schools.com/sql/sql_join.asp

http://www.tizag.com/sqlTutorial/sqljoin.php

“Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.”


Something like this?

SELECT 
  member.lastname,
  member.firstname
  membershipstatustype.memberstatustype_name
  membershiptype.membershiptype_name
  memberstomships.membertomship_lastdate
FROM 
  member
  INNER JOIN memberstomships ON member .member_id = memberstomships.memberid
  INNER JOIN membershipstatustype ON memberstomships.membershipstatusid = membershipstatustype.membershipstatusid 
  INNER JOIN membershiptype ON membershipstatustype.membershiptype_name = membershiptype.membershiptype_name 
WHERE
  UCASE(memberstomships.membertomship_paymentmethod) = 'MONEY'


Try this,

SELECT  Member.LastName,  Memebr.FirstName, memberstatustype_name, membershiptype_name, membertomship_lastdate,
FROM Members
 LEFT JOIN  Memberstomships
ON Memberstomships.member_Id = Members .member_Id
LEFT JOIN  membershipstatustype
ON membershipstatustype .membershipstatusid = Memberstomships.membershipstatusid 
LEFT JOIN membershipoption 
ON membershipoption .membershipoptionid = memberstomships.membershipoptionid 
LEFT JOIN  membershiptype
ON membershipstatustype .membershiptype_id = membershipoption .membershiptype_id
WHERE membertomship_paymentmethod =  'money'


Is better if you use the LIKE operator to compare strings.

P.S. Your tables and fields name are really hard to read. Correct them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜