473,749 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write this sql statement

1 New Member
i want to select a list of all user names and customer names. all names are in table 1 above. what does this sql statement look like?

assume two tables:

1. t1, columns id (unique generated value), and name (some char value)
for example, the t1 contains
1 customer name 1
2 customer name 2
3 user name 1 (at customer 1)
4 user name 1 (at customer 2)
5 user name 2 (at customer 1)

2. t2, columns customer name (an integer) and user name (an integer)

for example, the t2 contains
1 3
2 4
1 5

the sql statement i am looking for would show:

customer id/customer name/user id/user name
1/customer name 1/3/user name 1 (at customer 1)
2/customer name 2/4/user name 2 (at customer 2)
1/customer name 1/5/user name 2 (at customer 1)
Feb 21 '07 #1
1 1733
michaelb
534 Recognized Expert Contributor
I would beg you to rethink this design.
If I understand you correctly you have two entities: customers and users, and you need to maintain a relationship between them.

One common approach would be to have two tables, customers and users.
Then, depending on what type of relationship you need to maintain you will see whether you need yet another table.
If you have one-to-one relationship all you need is to have foreign keys on these tables.
If you have one-to-many or many-to-many relationship between customers and users, you should have the third table, something like
customer_id integer not null,
user_id integer not null

Finally don't forget to create indexes to speed up your queries.
Feb 21 '07 #2

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

Similar topics

0
1761
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is correct, but giving error says " file is accessed by other process cannot access" I have some logic inbetween and write the info using response.write in to html format Ex: Response.Write("<td>" & "client_no" & "</td>"). I am getting the error at :...
2
3878
by: Jack | last post by:
Hi, I am trying to check for the final sql statement before passing it to a database. I want to build the statement using user input in three text boxes. However, the sql statement does not give me the right statement. Instead it gives the following message: Error Type: Request object, ASP 0102 (0x80004005) The function expects a string as input. /sailors/loginverification1.asp, line 14 CODE:
1
3257
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt problem/question... The snippet of code in question is: <script language="JavaScript"><!-- document.write("<script src='/fp/"+includename+"'></script>"); // -->></script>
4
2951
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400, like DOS, uses memory-mapped display, two bytes per character (one char byte and one attribute byte). We can get the screen offset allright, and I've written a javascript which does the math to convert the offset into row/col (i.e. left, top)...
3
3411
by: TD | last post by:
I have an unbound form that adds and updates records to one table. I use an INSERT sql statment to add a new record and a UPDATE statement to update a record. I created a function named C2F to check each field for null. If the field is null I need to write the value null to the table. This is a sniplet of the UPDATE sql statement: sql = sql & "SSP4_Cut = '" & C2F(SSP4_Cut) & "', " that is:
1
8065
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example, "c:\temp\LogFile.txt". I see several articles for setting file access permissions, getting file access permissions for a given user or current user - but the current user could also gain write access to the same file not just by explicit permssion...
12
2096
by: =?Utf-8?B?Smlt?= | last post by:
I have code that reads and parses a text file using a schema.ini file. Works great. When I see the dataGrid it's exactly what I want. Dim CString As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\;" & _ "Extended Properties=""text;HDR=No;""" Dim TConnect As New System.Data.OleDb.OleDbConnection(CString)
23
2998
by: asit dhal | last post by:
hello friends, can anyone explain me how to use read() write() function in C. and also how to read a file from disk and show it on the monitor using onlu read(), write() function ??????
2
1664
by: chrisf01 | last post by:
I am trying to write to a text file and the database at the same time. I have a For statement that loops through all the repeated fields in my form and writes it to a text file. That part works 100% without a problem. My problem is that I also want to write to the SQL database at the same time and anytime I put the sql stored procedure inside the same For statement I get a http 500 error. Do I need to do this outside of the current For...
3
6816
by: Alan Mailer | last post by:
Ok, I've looked for an answer for this, because I'm sure it's been asked a thousand times... but no luck... so here goes. Imagine I want to create a NodeList based on an XPath statement. The 'query' portion of that statement wants to search for the following value: Joe's Garage ....now please note the APOSTROPHE in the above string.
0
9566
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...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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
6078
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
4608
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...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
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
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
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.