Jump to content

lordfa9

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by lordfa9

  1. I need to change the column name of one of my tables for example

    ItemID		  ItemName1					  Coffee

    changed to

    StockID		  StockName1					  Coffee

    i need an SQL statement to do that, i want the name to be changed (instead of using an AS command)I was also reading something about using the ALTER TABLE and ALTER COLUMN commands, are these the correct command(s) to use and if so, how do i use them in a statement?

  2. I see what you mean. You are going to need to look into GROUP BY and MAX()
    i think what he means is to use MAX(taskid) for the select statement and to use a 'GROUP BY CustID'i'm not sure about the group by thing though, i think you have to use DISTINCT(CustID) in your select statement
  3. select a,b,c,d,e,sum(f) from table group by a,b,c,d,e having sum(f)>0"
    i think you can try using WHERE here:select a,b,c,d,e,sum(f) from table WHERE X= bla blagroup by a,b,c,d,e, x having sum(f)>0"not sure if it works though, if not try removng the X from the group by clause
  4. SELECT department FROM yourtablename WHERE item_name NOT LIKE 'Geo positioning system'
    I think you missed out on soemthing the phrase you want to use for the LIKE statement should have a * at the start and endTry this
    SELECT department FROM yourtablename WHERE item_name NOT LIKE "*Geo positioning system*"

  5. Ooo so its like such:

    SELECT Stock.Item, Stock.Itemname, Sum(Stock.QTY) AS TOTAL_QUANTITYFROM StockGROUP BY Stock.ITEM, Stock.Itemname;

    So this means that all the rows not using the aggregrate function has to be added to the group by?

  6. doesn't matter if you write it all in one line or not.EDIT: just some guy is right you need to use & _ to tell your code it contuinues ont he next line....didn't see that part of the question when I posted.
    so you mean the code has to be like this?
    sql="SELECT Subcode, DateGiven, DateDue, Information & _FROM " & tblname & " & _Order BY " & sort & " " & ordering & "" & _

  7. recreated my file, seems to work now :)might be hardware or software though, i am now using a new platform.By the way, just a general query, when coding or coding general in notepad (Platform migration: Dreamweaver----> Notepad not good :) ). If i do the following to a piece of code will there be any difference?

    sql="SELECT Subcode, DateGiven, DateDue, Information FROM " & tblname & " Order BY " & sort & " " & ordering & ""

    typed in one complete line (notepad expands horizontally forever)or If i press enter to shift the various parts code to a new line eg.

    sql="SELECT Subcode, DateGiven, DateDue, Information FROM " & tblname & " Order BY " & sort & " " & ordering & ""

    will this affect the code? because i recall doing that before and it seems to cause a lot of funny errors, i didn't do it now and it seems alright :)

  8. I have the following SQL statementSELECT Stock.Itemcode, Sum(Stock.QTY) AS TOTAL_QUANTITYFROM StockGROUP BY Stock.Itemcode;This SQL works fine, however when I add itemname to the statement:SELECT Stock.Itemcode, Stock.Itemname, Sum(Stock.QTY) AS TOTAL_QUANTITYFROM StockGROUP BY Stock.ITEM; It gives me the error ‘You tried to execute a query that does not include the specified expression ‘itemname’ as part of an aggregate function’. Background: there may be more than one entry of the same item in the table (it’s a result of the merging of a few tables) and the first statement is to calculate the total number of each type of stock

  9. Let's say I have these two tables:LOC A

    Itemcode	QtyFish		1Meat		3Eggs		4

    LOC B

    Itemcode	QtyFish		4Meat		3Eggs		1

    How do I merge them together using a macro in Ms Access so that I get a table with the total of all the items? For example:

    Itemcode	QtyFish 		5Meat		6Eggs		5

  10. The Frame TagThe <frame> tag defines what HTML document to put into each frame In the example below we have a frameset with two columns. The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The HTML document "frame_a.htm" is put into the first column, and the HTML document "frame_b.htm" is put into the second column:<frameset cols="25%,75%"><frame src="frame_a.htm"><frame src="frame_b.htm"></frameset>
    I made a change to the figures (in bold) it helps me to explain easierI then will try to explain what is written:what the paragraph says is that the code will generate a frame where the page is divided into two parts downwards (imagine a line running down your screen), the page on the left (taking up 25% of the screen) is the page frame_a.htm while the one on the right is frame_b.html. Both pages are displayed on your screen at the same time, sharing space.Anyway I think it's best to use dreamweaver to create a frame, it allows you to set the hight and width easily.
  11. For example if you want to search for peppers in your "vegetables' table, your sql will be like thisSELECT * FROM vegetablesWHERE name LIKE "*peppers*"this will return red peppers, green peppers etc etcyou can substitute peppers for a user submitted value

  12. actually i really feel it depends on the situation that you are inif you want to do a couple of simple projects and never touch programming again, i really reccomend you learn ASp as w3schools can really provide everything you need and you can pick it up really fast :) if you are learning this as a longterm life skill then php is the way to go

  13. Hi Guys!I have problem : I have table Lottery include fields: ID,Name,Ticket1,Ticket2,Ticket3 ( With a user have max three ticket). I make a program use for Lottery (with Ticket1,ticket2,ticket3). I user random() function.I Want break up my table folow :I will add 2 field in to my table have name : Ticket and NewID and NewID field is Autocrement. With a user have three ticket .Example : ID Name Ticket1 Ticket2 Ticket3 23 John 001 003 112will Break up: NewID ID Name Ticket 1 23 John 001 2 23 John 003 3 23 John 112And finish : I will dial number in NewID use random() functionPlease help me
    I don't really understand :/Are you trying to convert your
    	   [b]ID		 Name		  Ticket1	Ticket2	Ticket3[/b]		23		 John			 001		  003		112

    table to this format?----->

       [b]NewID	  ID	  Name	   Ticket [/b] 		  1			23	   John		  001		  2			23	   John		  003		  3			23	   John		  112

    I was also thnking that since you want to do a lottery, world it be better to use the random() function on the ticket number and then using a JOIN to find out who owns the winning ticket?

  14. This may work:
    SELECT (SUM(LOCA.Quantity) + SUM(LOCB.Quantity)) AS 'Number of Fish'FROM LOCA, LOCB WHERE LOCA.StockID=LOCB.StockID AND LOCA.Stock = 'Fish' AND LOCB.Stock = 'Fish'

    I tried it and it didn't workI also noticed that you didn't use an inner join command, my database does not have any relationships so i think thats why it can't work.I was thinking, if i could use a sub query instead? For example to determine the quantity of fish that i have in LOCA, then submitting it where it will add that value to the number of fish in LOCB and give me a sum
  15. it may be Access not your code. Try running the same query in SQL mode in Access
    i'm quite sure it's not access because i ran the query there before using in in my script.As for error msg, i'm not sure cause i misplaced the file but i'll recreate it n get back to you, but i think it's something to do with being unable to excecute the query.
  16. SELECT SUM(Quantity) AS 'Number of Fish'FROM INVENTORY WHERE Stock = 'Fish'
    Thanks for that answer!If the fish is spread over 3 locations, for example there are 3 tables, one for each location, is there any way i can link then all using an inner join? for example:
    SELECT SUM(Quantity) AS 'Number of Fish'FROM LOCA INNER JOIN LOCB ON LOCA.StockID=LOCB.StockID WHERE Stock = 'Fish'

    LOCA and LOCB are the tables for the two diferent locationsi need to find out how much fish i have in all locations

  17. I was just wondering if anybody else has a problem with using inner join in ASP cause whenever i use an inner JOin command in my SQL query it always dosn't work For example:

    <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind.mdb"set rs=Server.CreateObject("ADODB.recordset")sql="SELECT Employees.NameFROM Employees INNER JOIN Orders ON Employees.Employee_ID=Orders.Employee_ID"rs.Open sql, conn%>

    is it my syntax?

  18. Ok lets say i have this tabeINVENTORY

    Stock				Location			   QuantityFish					 A						  2Fish					 B						  3Fish					 C						  4

    How do i write an SQL statement to find out what is the total amount of fish i have in all locations?

  19. i not really sure about the convert to excel part but if you are willing to use Ms Access as a go between (user types data into ASP form which is entered into Ms Access, whose tables you can convert to excel) u should read w3school's asp and ado tutorial 1st

×
×
  • Create New...