sql

Comment Moderation

I'm planning to create a custom system for comments. I was wondering about comment moderation. For approving comments, is it as simple as just creating a field called "Moderated" in MySQL? What's a good suggestion for countering spam? Akismat? ...

Database of registered users in ASP.NET MVC

Simple question. I know that in the default MVC application in Visual Studio, you can register a user. So I want to be able to put that info in a database and use ADO.net or LINQ to SQL to be able to communicate. How do I do this? ...

SQL Server: store more integers in a single value

I'm not sure how to explain this probably, so I'll use an example. I have to store (etc.) some users ID in a single value/column in my SQL Server table, so one value could look like this "4231 3271 3722 7432 4831 3192 ". of course this can be stored as a text, char, nchar, nvarchar and som on. But which is the best? if I have to only st...

How do I get a list with all reserved words in SQL::Parser?

Hi, with #!/usr/bin/perl use warnings; use strict; use 5.010; use SQL::Parser; my $parser = SQL::Parser->new( 'ANSI', {RaiseError=>1} ); my $word = 'BETWEEN'; my $success = $parser->feature( 'reserved_words', $word ); $success = $success ? '' : 'NOT'; say "$word is $success a reserved word"; I can ...

how can i rewrite a select query in this situation

Hello guys! Here are two table in parent/child relationship. What i need to do is to select students with there average mark: CREATE TABLE dbo.Students( Id int NOT NULL, Name varchar(15) NOT NULL, CONSTRAINT PK_Students PRIMARY KEY CLUSTERED ( CREATE TABLE [dbo].[Results]( Id int NOT NULL, Subject varchar(15) NOT NULL, Mark in...

Mysql INSERT SELECT problem (funny)

I have a table with primary key id AUTOINCREMENT and some other attributes. I have many rows with attribute lang='en'. and I do DELETE FROM ".MY_PRF."form WHERE `lang` <> 'en' I want to COPY all them changing lang to 'cz' I use: INSERT INTO form (`lang`, `caption`, `type`) SELECT 'cz', `caption`, `type` FROM form WHERE lang = 'e...

Create table query

I want to create a table for making a comment box. I was told that I should be wary of sql injection (dont even know what that means). So I thought I should ask around at SO. my requirements are: Comments table a comment row ~400 chars aid -> every comment should be linked to an aid. duplicates should be allowed. means aid = 21, can...

Count/GroupBy using Castle ActiveRecord

When using Castle ActiveRecord, how would you implement this query: SELECT vote, COUNT(*) FROM VotesOnQuestions WHERE questionid = x GROUP BY vote I would like to count all votes on a question, and group this by the vote value. ...

Need mySql query

I have n number of users with different articleId. If I pass the articleId, I want to get the results like how many different users viewed that article. Table 1: recId userId articleId ----- ------ -------- 100 1001 1 103 178 2 106 475 3 107 327 4 108 567 5...

SQL query - group by timespan in MySQL

I have a table containing the following details: date_info info 2009-06-23 1 2009-06-24 2 2009-06-25 20 2009-06-26 14 2009-06-27 17 2009-06-28 5 2009-06-29 10 2009-06-30 2 etc. I would like to group the info coloumn by occurrences per week and month, like so: 2009-06-01_2009-06-07 XXX 2009-06-08_2009-06-14 XXX Grouping by...

Need help with Scalar-valued function in SQL Server 2008

Hello, I need help with this scalar-valued function. What I want to do is to return the value I get in MaxValue on the line max(Value) AS MaxValue. The query works and will only return 1 value if ItemId and ListPropertyId exists, but I am not able to create a function of it. CREATE FUNCTION GetLpivMax ( -- Add the parameters for ...

check if fieldvalues exist?

i want to check if a column contains any fieldvalues in a table. cause i want to get the fieldvalues in a column and do something with them, but first i have to check whether they exist or not. i have tried: $query = "SELECT anonymous_username FROM users"; $result = mysqli_query($conn, $query) or die ("Couldn't execute query: " . mysq...

Getting a significant amount of data into a SQL Server (Express) database at time of deployment

For most database-backed projects I've worked on, there is a need to get "startup" or test data into the database before deploying the project. Examples of startup data: a table that lists all the countries in the world or a table that lists a bunch of colors that will be used to populate a color palette. I've been using a system where ...

Load Data Infile + Disable/Enable Keys Performance

I have a table with approximately 7 million rows. Once a day, I need to bulk import around 200,000 new rows into this table. To do this, I am first disabling keys on the table, using LOAD DATA INFILE, and then re-enabling keys on the table. The problem I am having is with the ALTER TABLE my_table ENABLE KEYS statement. It takes arou...

Creating A Search System from a SQL Server Database

I have recently created a search system at my company using the Regain Search based on Lucene to search through all software support tickets. I run some queries in SQL to extract my data, export to Excel, import to Access, run some additional queries, create a report, export the report to .txt files, and use a file splitter to split the ...

SQL Database Project in Visual Studio

Hi, I have a database ready which I am maintaining manually, I would like to now use that database to create an SQL project. I am creating also but not able to import the existing Tables, Views, Stored Procedures or any other object. Is there any way to do it. If yes please let me know. Thanks, Piyush ...

help with deleting relational tables

I have four tables: users: id, thread_id threads: id, language_id posts: id, user_id, language_id languages: id USERS.thread_id is a foreign key to THREADS.id, POSTS.user_id is foreign key to USERS.id and POSTS.language_id foreign key to LANGUAGES.id. I can't delete an user because the POSTS.user_id will throw a foreign key constrai...

Patterns for building social network type applications?

I need to design / architect / develop a web based social network type application. Basic functionality: - users create accounts on the system - users agree to "friend" each other - users create content within system - users specifies which friends may view/edit content that they created Surely this core functionality has been cr...

Specify Windows Username in SQL Script Without Knowing Machine Host Name

Hello, I'd like to reference a user account on a Windows machine, without knowing the host name of the machine. Specifically, I am assigning permissions on a SQL server database, in a sql script, that will give permissions to a local user account on that machine. For example: CREATE USER [UserA] FOR LOGIN [MACHINENAME\UserA] WITH DEFA...

Using sets as inparameters to function/sproc in SQL Server 2008?

Hello! Is it possible to use a set, like (1, 2, 3, 4, 5) for example, as inparameter to a Sproc, function or view in SQL Server 2008? What should I use of Sproc, function or View for this pice of SLQ? WITH Scores AS( SELECT ItemId, SUM(Score) AS Score FROM [Presenta].[presenta].[LpivScores] WHERE // HERE ...