473,671 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create table using joins

17 New Member
Please help me. iTs very urgent.

I have three Tables
1 Student_master:
stu_id(pk),name ,phoneno,father name,address,co llegename,class ,photo;

2 Student_detail
slno(pk),stu_id (fk), subject,teacher name,stu_name,b atchday,batchti me

3 fee_detail
stu_id(fk),Tota l amount, Paid amount;

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

stu_id,stu_name ,classname,subj ect,paidMoney where teachername=som evalue

i tried to write the query but i failed.
plz anyone can help me .
i advancely thanks .
May 1 '07 #1
10 2051
iburyak
1,017 Recognized Expert Top Contributor
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 New Member
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.St u_name as studentName,sm. className as cname,sd.subjec t as ssubject,fd.Pai d_Money as paidmoney from xiStu_detail sd join xiStudent_maste r sm on sd.stu_id=sm.st u_id join fee_Detail fd on sd.stu_id=fd.st u_id where Teachername='KK K'

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

Try this:

[PHP]
Select *
from xiStu_detail sd
join xiStudent_maste r 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 Recognized Expert Top Contributor
Check this table's name

from xiStu_detail sd

Maybe it should be

from xiStudent_detai l sd
May 2 '07 #5
mina10a
17 New Member
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 Recognized Expert Top Contributor
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 New Member
thanks its working.
thank u for help me
May 4 '07 #8
mina10a
17 New Member
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_adv Master ON [dbo].[Adv_Master]
for update
as
insert into trig_delete_adv Master(deleteti me,operation,ad v_code,memship_ no,memship_dt,e nrollmt_no,enro llmt_dt,auth_en rolled,oth_bar_ association,led ger_id,id_card_ no,library_mems hip_no,adv_name ,dob,gender,off _add,res_add,ch _add,off_phone, res_phone,ch_ph one,fax,mobile, email,type_of_m emship,father_h usband_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 Recognized Expert Top Contributor
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

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

Similar topics

3
3475
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 me how to form the syntax but it is always shown in MySQL interactive mode and not using PHP code so I have to try and figure it out in PHP (I've already opened mysql and selected the database):
2
2666
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 less normalised, but seems less computationally expensive to me(?). Basicially what I have is: Friend (uid1,uid2,fid) -> FriendshipCategories(fid,cid) -> Categories(cid,name) If I want to find out all the 'categories' (names) which a user...
3
1578
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 experienced - but Im not. Allow me to explain: I have 2 Tables: PERSON and SIGN PERSON
4
6756
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 trying to do is make a select query with not one but two fields in the join, that will allow me to update the LName field . IE SELECT FirstName.FName, LastName.LName, FirstName.ID, FirstName.Number,
7
1133
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. Does anyone now how I would acheive this, I don't want to have to loop through each record in the dataset and do a separate insert for each record as there can be allot of records, and this would result in a waste for recourses.
4
1916
by: staeri | last post by:
I have the two following tables: tblProject: ProjectID 5001 5002 6001 6002 7001 7002
20
2554
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 based on a common ID from an ID session table. So we can have various session tables with differing results but if they contain records, they are all keyed to the common ID. My problem now however is how do I report the overall findings of the
2
5762
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 to the widget itself. I then have a WidgetSale table which stores only information related to the sale of the widget (advertised price, headline, copy, date of sale
4
2423
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. I've tried manipulating queries, relationships different table joins but to no avail. I'm only a beginner in VBA and know little SQL, I would be truly gratefull if someone can please shed some light on the below. I've been creating a...
10
2247
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 suggested I redesigned my database to use more tables of info. Before I had 1 table for image information, now I have 9 and it's getting very, very confusing... especially as I don't know much about joins...! I am using ASP, MySQL, IIS and VBScript. ...
0
8485
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8403
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.