473,395 Members | 1,941 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,395 software developers and data experts.

Create table using joins

17
Please help me. iTs very urgent.

I have three Tables
1 Student_master:
stu_id(pk),name,phoneno,fathername,address,college name,class,photo;

2 Student_detail
slno(pk),stu_id(fk), subject,teachername,stu_name,batchday,batchtime

3 fee_detail
stu_id(fk),Total amount, Paid amount;

my problem is that i have to retrieve the following fields where teachername is given.

stu_id,stu_name,classname,subject,paidMoney where teachername=somevalue

i tried to write the query but i failed.
plz anyone can help me .
i advancely thanks .
May 1 '07 #1
10 2038
iburyak
1,017 Expert 512MB
Try this:

[PHP]
Select sd.stu_id, sm.name as stu_name, sm.class as classname, sd.subject, [Paid amount] as paidMoney
From Student_detail sd
Join Student_master sm on sd.stu_id = sm.stu_id
Join fee_detail fd on sd.stu_id = fd.stu_id
Where teachername = somevalue[/PHP]

Good Luck
May 1 '07 #2
mina10a
17
hi thanks for help
i trid this query. but it gives the error as

Syntax error near from Clause

I give the query which i write:

select sd.stu_id,sm.Stu_name as studentName,sm.className as cname,sd.subject as ssubject,fd.Paid_Money as paidmoney from xiStu_detail sd join xiStudent_master sm on sd.stu_id=sm.stu_id join fee_Detail fd on sd.stu_id=fd.stu_id where Teachername='KKK'

where is the error i could not find.
if u give me solution i grateful to u.
May 2 '07 #3
iburyak
1,017 Expert 512MB
Everything looks good.

Try this:

[PHP]
Select *
from xiStu_detail sd
join xiStudent_master sm on sd.stu_id = sm.stu_id
join fee_Detail fd on sd.stu_id = fd.stu_id
where Teachername = 'KKK'[/PHP]

Let me know if you have an error this way.
May 2 '07 #4
iburyak
1,017 Expert 512MB
Check this table's name

from xiStu_detail sd

Maybe it should be

from xiStudent_detail sd
May 2 '07 #5
mina10a
17
thanks .
its work.
now i want to write an trigger. so i dont know how to write trigger.
if any records from my student_master table is changed or deleted a trigger is fired.
all the old data wihch is updated is transfer to the new table
and new data is update in the student master able.
when record is delete the deleted record is enter to the new table and delete from the student_master table.

sorry for my language.plz help me
and thanks
May 3 '07 #6
iburyak
1,017 Expert 512MB
It should look something like this:

[PHP]

Create trigger tIU_TableName ON TableName FOR DELETE,UPDATE
AS
BEGIN
Insert into NewTable
Select * from deleted
END

[/PHP]

Don't forget to change table names.

Good Luck
May 3 '07 #7
mina10a
17
thanks its working.
thank u for help me
May 4 '07 #8
mina10a
17
hi i write an update triggre
it works fine . but it adds two record of the updated record in new table
my trigger code is as follow:

CREATE TRIGGER trig_update_advMaster ON [dbo].[Adv_Master]
for update
as
insert into trig_delete_advMaster(deletetime,operation,adv_cod e,memship_no,memship_dt,enrollmt_no,enrollmt_dt,au th_enrolled,oth_bar_association,ledger_id,id_card_ no,library_memship_no,adv_name,dob,gender,off_add, res_add,ch_add,off_phone,res_phone,ch_phone,fax,mo bile,email,type_of_memship,father_husband_name,des ignation,status,extra_info) select getdate() as dt,'Update' as op,* from deleted

where is the error i m unable to find. plz help me. what is wrong with this code
May 4 '07 #9
iburyak
1,017 Expert 512MB
Check if you have duplicates in a table. It is most possilbe cause of a problem.
When you do update how many records is actually updated?

Also you can do this but it is not a cause of a problem and I wouldn't recomend it:

[PHP]
select distinct getdate() as dt,'Update' as op,* from deleted [/PHP]

Good Luck.
May 4 '07 #10
mina10a
17
Check if you have duplicates in a table. It is most possilbe cause of a problem.
When you do update how many records is actually updated?

Also you can do this but it is not a cause of a problem and I wouldn't recomend it:

[PHP]
select distinct getdate() as dt,'Update' as op,* from deleted [/PHP]

Good Luck.
thanks .its working.
thank u very much.
May 5 '07 #11

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

Similar topics

3
by: Ralph Freshour | last post by:
I am having a hard time with joins - my following code displays: ..member_name .gender instead of the actual data - I've been reading through my PHP and MySQL manuals - the MySQL manual tells...
2
by: terence.parker | last post by:
I am often faced with the dilemma of whether to use a JOIN query across three tables in order to grab a bunch of results - or whether to create another table to represent what I want. The latter is...
3
by: Jack Smith | last post by:
Hello, I want to be able to view data from 3 tables using the JOIN statement, but I'm not sure of how to do it. I think i don't know the syntax of the joins.I imagine this is easy for the...
4
by: adolph | last post by:
I created 2 tables, each with an autonumber primary key. Fields are: ID (autonumber Primary key) Number (single) Color (Text) FName (text)in one table and LName (text)in the other What I'm...
7
by: Jake | last post by:
Hi all, I am trying to update an SQL server table from a dataset populated by an excel spread sheet. Each record has a check box so it can be excluded from the SQL server table population. ...
4
by: staeri | last post by:
I have the two following tables: tblProject: ProjectID 5001 5002 6001 6002 7001 7002
20
by: p175 | last post by:
Hi people, I have a stored procedure that creates many Global temporary session tables. Into each of these tables go the results of various processing using relational division all keyed and...
2
by: Jody | last post by:
Hi I've been working on a database which basically incorporates 3 tables to describe say a widget which is either sold or leased. I have the Widget table which stores the information related...
4
by: colonial | last post by:
I was wondering if what I'm trying to do in Access XP and 2003 is possible. I've looked at countless templates and samples and havn't seen anything like what I want to do to be able to construct it....
10
by: marting | last post by:
Before I throw my new expensive laptop out of the window! I'm stuck on getting my joins right with the correct amount in a column count. After speaking with someone a few weeks back, they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.