/    Sign up×
Community /Pin to ProfileBookmark

how to display single record

hi …………..

how to display single record from two table in same database having one common field.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@abou_hmedJun 01.2006 — select table1.fieldname

from table1 INNER JOIN table2 on table1.commonField=table2.commonField

where ....
Copy linkTweet thisAlerts:
@jenyJun 02.2006 — We can use a view to apply joins to two tables. In this case, users only see one view rather than two tables when they need to combine the information from these two tables. Let's say we have the following two tables:

[B]Table Store_Information [/B]

store_name Sales Date

Los Angeles $1500 Jan-05-1999

San Diego $250 Jan-07-1999

Los Angeles $300 Jan-08-1999

Boston $700 Jan-08-1999

[B]Table Geography [/B]

region_name store_name

East Boston

East New York

West Los Angeles

West San Diego

and we want to build a view that has sales by region information. We would issue the following SQL statement:

CREATE VIEW V_REGION_SALES

AS SELECT A1.region_name REGION, SUM(A2.Sales) SALES

FROM Geography A1, Store_Information A2

WHERE A1.store_name = A2.store_name

GROUP BY A1.region_name

This gives us a view, V_REGION_SALES, that has been defined to store sales by region records. If we want to find out the content of this view, we type in,

SELECT * FROM V_REGION_SALES

Result:

REGION SALES

East $700

West $2050
Copy linkTweet thisAlerts:
@abou_hmedJun 02.2006 — you can't use the view in mysql ?
Copy linkTweet thisAlerts:
@anupriyaauthorJun 03.2006 — thanks
Copy linkTweet thisAlerts:
@anupriyaauthorJun 03.2006 — thanks for abou.hmed ?
×

Success!

Help @anupriya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...