[DELETED] 17:53 21 Aug 2003

does anyone kno how to create column headings in oracle SQL, when exicutin a query, i want the results to be displayed under appropriate headings in their columns


  [DELETED] 19:17 21 Aug 2003

There are more ways of writing SQL queries than you can shake a stcik at and the method you use could be a factor here.

Normally you would simply write your SQL query as follows:



This obviously pulls the customer ID number and their name from the table called customer.

Oracle SQL can specify the output column title of a query field by assigning your own title or value to it in quote marks. You could run a calculation for example, and force the output to be listed under your own prefered column headings, along the lines of:



This would pull out the employee name and department then would multiply their weekly wage plus overtime by four and output the numerical value under a column titled MONTHLY SALARY.

If you are running command line queries for Oracle or any one of several other methods, you may need to include \t or -t to toggle or disable headers, but since you seem to have the reverse problem where you can't get the column headings out I think I need to know how you are querying the database. And don't try and use Access SQL syntax because it's different to other database SQL in many respects.

Without further details I can't really advise much and it's been a while since I played with Oracle in depth, but get back to me and we'll see what we can do for you.



  [DELETED] 19:19 21 Aug 2003

My apologies for the typos.

I posted without spell-checking.


  [DELETED] 13:37 22 Aug 2003

thanks for that, im writing my queries in the format that u hav used in your response, so is that how u display the data in columns,

using "", to name the columns?

So if i had a libary system, with tables called BOOK, LOAN, and i wanted to search for a book with ISBN 0-201-30978-5 and display the date that it was first borrowed along with the amount of times that it has been borrowed, how would i do that? If the date is stored in a column called DATE_ISSUED, in LOAN table.

Also im not to sure what relational algebra expressions are, do you know?

thanks once again


  [DELETED] 19:59 22 Aug 2003

The quote marks allow you to specify the name of a column to display the information you pull out of the database using your query. Not using quotes should just display the columns as they are named in your tables. Either way, you should have some sort of column heading.

Relational algebra expressions vary, but the simpler examples include JOINS and SELECTS.

I need to know your table names AND the field names of what's in them to correctly formulate a workable query for you.

You should have one field that includes unique ID number, perhaps a title, author and so on.

Once again, more information please, and I'll do what I can for you.



  [DELETED] 21:48 22 Aug 2003

right thanks, its just that im new to this and still figuring it out.

I have a table called book, there are columns called: ISBN(primary key), title and author. Then i hav a table called LOAN, with columns: book_no(which is a foreign key, ISBN from book table), borrower(primary key), Date_issued, date _returned.

then i am tryin to write a query which will select a book with the ISBN 0-201-305122-7 and find out when it was first borrowed and also the total amount of times that it has been borrowed from the libary. i was hoping to hav headings for the returned data such as: ISBN, First borrowed and amount of times borrowed.



  [DELETED] 12:38 23 Aug 2003

Sorry to be really pedantic, but can you confirm that I have this correct:

Table 1

Tablename: Book

Fieldname:ISBN (primary key)

Fieldname: Title

Fieldname: Author


Table 2

Tablename: LOAN

Fieldname: Borrower (primary key)

Fieldname: Book_No (foreign key)

Fieldname: Date_Issued

Fieldname: Date_Returned


If this is correct, confirm it for me and I'll cook something up for you.

Incidentally, your table structure may need a little tweaking, depending on how much information you want to be able to enter and manipulate. I'd suggest you consider Table 2 to have the following fields: BorrowerID (pk), ISBN_No, Issue_Date, Return_Date then you could add a confirmation field to log that the book has indeed been returned and booked back into available stock to re-lend. At the moment there is nothing in place to tell you whether an item is in or out and while I appreciate that this can be achieved through queries, it can be handy to include the fields in your tables for manual or automatic input once you get your queries sorted out.

You could also consider adding a lender table with the book lender credentials, along the lines of:

LenderID (pk), Name, Surname, followed by address or department details. These should be broken down into Address1, Address2, town/city, postcode, tel_no, fax_no, email and so on, with however many fields are relevant to storing lender details.

Creating a simple library database is not too difficult and it's always a good learning model. The trouble most people have is in designing and relating the appropriate table structure, which obviously will include those details you do and do not want to store. Having a lender ID is all well and good, but not having any reference to the lender details other than an ID number means you only know a person by ID and have no other tracking methods in place.

Have a bit of a think about what you might want to include for data input, closely followed by what you would like to be able to pull out of the database. At first glance, I would say that you need to know whether an item is in or out, who has it if it is out and when it will be returned. While you could manage that (just) with your current structure, you are very limited in what you can get out if it.



  [DELETED] 12:14 24 Aug 2003

The tables that you listed above are correct, they are the ones which i have in my dadtabase, i have considered ur suggestions and i feel that they will make the database much more useful. thanks

so wud u beable to help me with the querie that i used above? so that i can get an idea about how to do them



This thread is now locked and can not be replied to.

Elsewhere on IDG sites

How to watch the World Cup for free on TV and online

Meet Superfiction, the little design studio with a load of character

Best Mac music-production software

Comment savoir si votre message a été lu sur Facebook & WhatsApp ?