By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

mysql query problem

P: 31
I am making a seed bank database in which seeds are either collected from location or donated by organization.So I have made a supertype table acquisition and subtypes are collection and donation.
I want to display the information of all seeds regarding their collection and donation. For this I am building a sql query from different tables and displaying it in single form.I cannot make the correct query there is problem in it. Tables in which i am having problem are:
Acquisition:Coll_Don_no.,date,quantity,Accid (it is a supertype table)
Subtypes of this table are:
Collection:Coll_Don_no(foreign key),longitude,latitude,altitude,town
Donation:Coll_Don_no(foreign key),origin
As seeds are either collected or donated not the both so query i have made is
Expand|Select|Wrap|Line Numbers
  1. "Select original.Acc_ID,
  2. crops.crop_id,crops.common_name,crops.genus,crops.specie,
  3. seeds.Seed_ID,acquisition.Coll_Don_no,donation.origin,collection.longitude,collection.latitude,collection.altitude
  4. from original,crops,seeds ,acquisition,donation,collection
  5. where original.Seed_ID=seeds.Seed_ID 
  6. and 
  7. seeds.crop_id=crops.crop_id
  8. and
  9. acquisition.Acc_ID=original.Acc_ID
  10. and
  11. (acquisition.Coll_Don_no=donation.Coll_Don_no
  12. OR acquisition.Coll_Don_no=collection.Coll_Don_no)"
  13.  
But it is displaying duplicated and wrong information.I know there is some error in mysql query.when i use AND at the place last "OR" then nothing is displayed.Plz helpout
Jun 28 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,359
Without complete table definitions, sample data, and sample results (both wrong and right), there's no way to know.
Jun 28 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.