Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In PHP, I would like to run a query that would delete every row in a database that had the ID of less than a figure.
The context I want to use it in, is running a PHP CRON job every 24 hours that will delete all rows with values in the 'time' column that are LESS THAN time();
Putting it in to another context: I want to run a query that will delete every row that has an ID of ~10.
Thanks
I imagine you are not very familiar with SQL. This is a simple delete statement:
delete from t
where id < 10;
This assumes that by "database", you really mean "table". It also makes some other assumptions about foreign key references in other tables. Because the question seems so basic, I am guessing these are not issues.
However, I would recommend that you study up a bit on databases if you are going to use them in your applications.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have two tables stored on phpmyadmin, 'gigs' and 'bands'.
gigs: "gigID, gigBand, gigDate"
bands: "bandID, bandName, bandGenre...."
gigBand is a integer which corresponds to the bandID. I am aiming to diplay all the available gigs, but show the actual band name rather than the number. I have read table joins are the easiest way of doing this, and I have no trouble displaying the data of 'gigs' on the webpage.
But managing to display the name rather than the value is proving very difficult.
Any advice, or even an example of the code would be greatly appreciated.
You need to use a MySQL JOIN to pull the records of two related tables.
http://dev.mysql.com/doc/refman/5.7/en/join.html
SELECT * from gigs
INNER JOIN bands ON gigBand = bandID
This is pretty basic stuff though, so I would strongly recommend taking the time to do a bit more research. This seems like a good place to start:
http://www.tutorialspoint.com/mysql/index.htm
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a table wich contains:
RO;DE;ES;AU;IT;
How display data where DE is show on table! I need for milions queries!
It seems like you have multiple values in the same "cell". You will need to process the string. One way is to use wildcards:
SELECT something FROM something WHERE field LIKE '%DE%'
Please note however that your table design is absolutely terrible. It violates the first normal form. You should never have multiple values in a single cell that you then have to split using wildcards or other string functions. This adds overhead to your queries and will slow them down significantly. You say that you have millions of records, the impact of not having separate values has the potential to be quite large.
You should definitely think of breaking those strings into multiple records if you can.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a table, codes, with 3 columns (code, email, sent).
How do I call on the first X number of rows of table codes and assign each individual code (in code column) a variable with ordered numbers? (ie $code1, $code2, $code3, $code4)
Now, I will be calling on a multiple of 10 rows (10 rows, 20 rows, 30 rows) at a time so I need to be able to call on these codes individually for other procedures.
Thanks so much for the help!
Try putting the results in an array. Then call on them by using $code['1'] or what ever you are looking for
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to create something like this:
I've been able to create it statically, just type int everything fixed in the code. I want to have it done dynamically, I've built the database which consists of all the data I need to have in this table.
But what I can't figure out how to achieve is the first two rows (Day and Date). Other than that, I can fill all from the data base (Group Members and data associated with.
Can someone direct me on how to achieve first two rows? or should I also set them with the data in the database?
EDIT
I need at least how to convert the day (1-Nov) to day. I will use current year (2013) or next year (2014) for now.
You may usefull following links. you can start from here and then can analyse there codes.
link 1 link 2
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm using postgresql database. I want to do an pagination for my articles, but i have no idea how to do it. I havent found a solution for postgresql (found some for mysql).
This is my query.
$user->getUsers(); - I call method, which is doing query..
function getUsers()
{
$this->querySelect("SELECT vk_id, eu_name, eu_data, eu_society, eu_want_team, eu_notes, eu_main_profession, eu_avatar FROM users");
}
I have read, that query should contain LIMIT, but it just only limit the results quantity. Can anybody tell me how to do that pagination please?
Will be very thankful..
If you really want Postgresql to do this, you're looking for OFFSET and LIMIT combined.
LIMIT means no more than that many rows will be returned.
OFFSET says to skip that many rows before beginning to return rows.
Also, you have to have an ORDER BY clause on your query for this to work.
You'll have to keep track of the page size and which page you are on.
Here is a relevant documentation page (Postgresql 8.4)
http://www.postgresql.org/docs/8.4/static/queries-limit.html