Skip to content
Advertisement

How to create a table address and query it by states?

How can I create a table with following schema:

How can I create a table with following schema

I wrote the above query for creating the table.

But I’m not able to link this table to another table for the query shown below and fetch all state names and total of account balance for the users belonging to those states.

Advertisement

Answer

You should be able to use something like this to query out records:

Let’s take an example.

These are two records – one for maharashtra and one for gujarat.

In your account able, you have 2 records as well like so:

When you run the query, you will get results for just maharastra.

See example here: http://sqlfiddle.com/#!18/c56741/1

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement