Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4325230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:14:20+00:00 2026-05-21T09:14:20+00:00

I have two tables in my SQL database: mysql> select *from crop; +——+———–+———-+ |

  • 0

I have two tables in my SQL database:

mysql> select *from crop;
+------+-----------+----------+
| no   | name      | type     |
+------+-----------+----------+
| 1    | pineapple | fruits   |
| 2    | wheat     | mainFood |
| 1    | apple     | fruits   |
| 2    | corn      | main     |
| 3    | rose      | flower   |
| 2    | wheat     | main     |
| 2    | maize     | main     |
| 1    | drydates  | fruits   |
+------+-----------+----------+

mysql> select *from enviornment;
+---------+------------+----------+------+
| climate | irrigation | soil     | no   |
+---------+------------+----------+------+
| humid   | medium     | alluvial | 2    |
| humid   | medium     | black    | 1    |
| humid   | medium     | red      | 1    |
| sunny   | low        | black    | 1    |
| sunny   | medium     | alluvial | 1    |
| wet     | high       | red      | 2    |
| humid   | low        | red      | 3    |
+---------+------------+----------+------+

I want to get the name and type fields from the crop table, based on climate, soil, and irrigation.

I have written my query in the following way:

mysql> select T.name from((select name from crop)as T and (select no from envior
nment where climate like wet)as U)where T.no=U.no;

But when I try to execute it, I get the following error:

ERROR 1064 (42000): 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 ‘and (select no from enviornment where climate like wet)as U)where T.no=U.no’ at line 1

Can anyone tell me how to re-write my query to avoid this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:14:20+00:00Added an answer on May 21, 2026 at 9:14 am

    You cannot use AND to construct query-results, it’s a logical operator. You can get all name, type, climate, soil and irrigation combinations with:

    select c.name, c.type, e.climate, e.soil, e.irrigation
    from crop c, environment e
    where c.no = e.no; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in my SQL database: Company: ID (autoincrement) name address ...
I have two tables from two different databases. For example: Table: Articles1 - Database:
I have the SQL text SELECT * FROM TABLE1 WITH (NOLOCK). Two questions: How
I'm wondering if this is possible in SQL. Say you have two tables A
We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType
I have two tables in my database, called ratings and movies . Ratings: |
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two database tables: "places" and "translations". The translations of places names are
I have two tables that are joined together. A has many B Normally you
I have two tables, Book and Tag , and books are tagged using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.