To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Related Sites > SQL Course

SQL Course SQL Course > Ask questions about the lessons on SQL Course 1 and 2. If you have problems > with the interface, please post in the Feedback forum

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 02-20-2003, 11:39 AM
djl3779 djl3779 is offline
Junior Member
 
Join Date: Feb 2003
Posts: 2
select statement

Hello,

I'm new to this. I'm trying to build a print quota system from data in several mysql tables.

The important tables and columns are:

table1: job_id user_name
table2: job_id sheets_printed
table3: user_name total_sheets_printed

I wanted to make a statement that would UPDATE table3's total_sheets_printed by table2's sheets_printed if table1's user_name is equal to table3's username.
(The job_id's in table1 and table2 will match up.)

A big sticking point is that the user_name column in table1 is in the form (username@server). I'd like to chop that @server off temporarily for comparison between table3 and table1 (table1's user_name is simply the username).

Also, I'd like the statement to INSERT a new record if a user printed paper, but did not exist in table3.

BTW, I hacked together a script in perl to do all this, but I'd like to know if this is possible to do with sql statements.

Thanks,
Danny
Reply With Quote
  #2  
Old 02-25-2003, 06:52 PM
Joecool Joecool is offline
Junior Member
 
Join Date: Feb 2003
Posts: 4
First thing I would do is normalize your data. It decreases total space needed for the database and makes queries quicker.

Table1:UserID, UserName, TotalSheetsPrinted
Table2:JobID, UserID, SheetsPrinted

I do not see a reason to have seperate tables for user_name and total_sheets_printed.

I will add to this later, at work right now.

Joe
Reply With Quote
  #3  
Old 02-25-2003, 11:41 PM
djl3779 djl3779 is offline
Junior Member
 
Join Date: Feb 2003
Posts: 2
Unfortunately, just normalizing the tables isn't that straightforward.

Markvision 10 (the printer management software) creates the majority of the tables. This software is closed. The only leeway I have is with the 3rd table or any temporary tables.

Last edited by djl3779; 02-25-2003 at 11:46 PM.
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:53 PM.


DatabaseJournal Recent Articles


 » Grouping with SQL Server 2008

 » Conducting Service Broker Conversation Usi...

 » SQL Server Consolidation Initiative Under ...

 » Transaction Log Growth, do you need it?

 » New FileMaker Pro 10 Ships With Sleek New ...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.