473,414 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

retrieve two tables in a single query

I have to retrieve two tables which are not having any relation in a single query itself
for example
select * from memberphoto;select * from restricconfig;

if i execute this query only restricconfig table is viewed but i want both table to be retrieved simultaneously in a single query


advance thanks
kirthika
Jul 28 '07 #1
10 6401
michaelb
534 Expert 512MB
If your tables have compatible structures you can use the UNION clause. Also see combining queries

Combining query results is not something people do very often, and one reason for that is that this is rarely justified.
Think again before you do this and make sure you are not working around some problem that should have been addressed either in database design, or somewhere else in the application.
Jul 29 '07 #2
michaelb
534 Expert 512MB
thanka michaelb
but i want to retrieve two tables which has no relation and second table is having more rows than first one. and i want the result to show two tables displaying the rows of two tables separately.
pls is there any possible way. I can do this in sqlserver but i can't do it here. if any one know pls help me

thanks in advance
kirthika
kirthika, please append to existing thread rather than making a new one.
If you have any doubts about using this forum it may be helpful to review the Posting Guidelines at the top of the Forum.
Jul 30 '07 #3
kirthika, please append to existing thread rather than making a new one.
If you have any doubts about using this forum it may be helpful to review the Posting Guidelines at the top of the Forum.
michaelb, please tell be how append to existing thread i can't understand
Aug 1 '07 #4
michaelb
534 Expert 512MB
You just did!
I made this suggestion because your previous append was made as a brand new thread (I had to copy it into the correct thread), but this time you actually appended to the thread.

Basically there are two ways of doing that.
First, you click on the title and expand the thread, so you can see all individual messages in it.
Then, you can either
A) click on the Reply link at the bottom of an individual message,
or
B) click on the post reply link at the bottom of the entire thread.

The only difference between A and B is that with A your reply will include the quote of the message you are replying to, while with B your reply will have nothing else, only the message you typed in.
Aug 1 '07 #5
michaelb
534 Expert 512MB
... ... ...
but i want to retrieve two tables which has no relation and second table is having more rows than first one. and i want the result to show two tables displaying the rows of two tables separately.
... ...
But this does not mean that you need to fetch the data from two tables in a single query!

Let's start with your environment:
- Are you using some kind of the client API to access the database?
- Where all this data supposed to be displayed?

For example, if you have a web application and you using PHP for the server side scripting, you can run two queries, each for a different table, save the results, then display these results in two different places (perhaps with HTML tables) on your page.
Aug 1 '07 #6
But this does not mean that you need to fetch the data from two tables in a single query!

Let's start with your environment:
- Are you using some kind of the client API to access the database?
- Where all this data supposed to be displayed?

For example, if you have a web application and you using PHP for the server side scripting, you can run two queries, each for a different table, save the results, then display these results in two different places (perhaps with HTML tables) on your page.
i can't understand what are saying?
Aug 1 '07 #7
michaelb
534 Expert 512MB
Just tell us more about your particular programming and application environment.
Let's start with where you are running your queries, and where and how the result of these queries should be displayed.
Aug 1 '07 #8
Just tell us more about your particular programming and application environment.
Let's start with where you are running your queries, and where and how the result of these queries should be displayed.
I am doing my project in .net but i want retrieve data from two tables but in a single query
Expand|Select|Wrap|Line Numbers
  1. select * from table1;select * from table2;
  2.  
if i execute this query only the second table datas are retrieved but i want both table's data one after the other. This is possible in SQL Server. but it is not working in postgreSQL please help me to solve this.......

Thanks in advance,
kirthika.
Aug 28 '07 #9
michaelb
534 Expert 512MB
I do not work with .NET, but I'd think you need to save the result of the first query, practically assign it to some variable or, object.
I'm sure .NET has an appropriate object for this, some kind of ResultSet.

And frankly it just seems wrong to string together two queries... what are you trying to achieve by doing this?
Aug 30 '07 #10
Hi Krithika,

Did you get a soln for your query?

I too got stuck in the same problem.

Please provide me solns if any.

Thank You.
Dec 18 '07 #11

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

Similar topics

1
by: Bob Kaku | last post by:
I'm trying to retrieve a text value from a MySQL database, put it into an updateable form, allow edits, and send back the edited text back into the MySQL database. I've been able to successfully...
0
by: Dimitris Katsikas | last post by:
Hi everybody, I am trying to find a way to export automatically an entire database schema into an .xsd A graphical way is to drag & drop the tables from Server Connection into an empty .xsd...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
7
by: Peter | last post by:
Gday, I have a dataset with multiple tables, from which I want to access a single value in one of those tables. I know I can do something like: Decimal myVar =...
6
by: zoro | last post by:
Hi, I am looking for the recommended way to retrieve several values from a single record, i.e. a typical lookup scenario. An example would be a query that needs to retrieve user_name, user_addres,...
2
by: SueA | last post by:
Can anyone help me with the code to retrieve the name of the table that a control on a form (that's built off a query) refers to? For instance: qryMfrsAndBrands is based on the tables:...
10
by: Jim Devenish | last post by:
I have a split front end/back end system. However I create a number of local tables to carry out certain operations. There is a tendency for the front end to bloat so I have set 'compact on...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
0
by: Serman D. | last post by:
Hi, I can't understand why mysql allows me to grant lock tables to all tables in a particular database, while it fails to accept the same command applied to a single table only. I've tested on...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.