Is there any software for Windows that allows you to setup your tables and then tell the software what you want to SELECT given the conditions and it will tell you the SQL query that you need? Thanks.
Probably you'll find software that will do this for you in a GUI, but eventually you will be required to write the queries yourself, unless you're developing something really trivial.
A GUI tool for SELECT statements is a too-high level of abstraction for most scenarios, and you would have to face the "Law of Leaky Abstractions" eventually.
Visualization tools are quite handy for defining the database schema, and there are some very good tools for that. However queries remain quite tricky to visualize, in my opinion. I think you'll be able to mentally visualize queries, given enough practice. Nevertheless, I'm quite sure you will be able to get started doing SQL queries within a few days, even non-trivial ones.
In addition, you can use Stackoverflow if you require assistance with complicated queries. I'm quite sure that the community here will suggest better SQL than any GUI tool!
These sound like they will do what you want:
SQL Maestro
dbForge Query Builder for MySQL
Having said that, I do agree with the other answers here - learning to manually write SQL will give you a lot more control. I highly recommend the (free) MySQL Workbench for that.
The people at sqlmanager.net build some tools to deal with databases, but I agree with Daniel: if you have very complex queries to work with, it's probably more work telling the tool what to do that creating the queries manually - especially as you'll have to verify what the tool did, so if you can do that, you could have done it by hand in the first place :)
As said before by daniel vassallo, you should learn how to create those sql queries "by hand". where i work we use a program that does exactly this (it's used by accountants only) and it creates horrible sql select statements and we have constantly whining accountants that think that the problem is allways on the server side even when we show them that those queries get them the wrong data... it's a never ending circle :(
Use HeidiSQL to manage your database, and keep an eye on what's going on in the SQL log. You'll soon pick it up.
Related
Thanks in advance.
Is there a tutorial (preferablly free) out there that'll walk me through how to write mySQL statements?
I'm not interested in learning about installing and configuring mySQL since this is something handled by experts and I wouldn't have permissions to do this anyway.
Specifically, what I'm looking for is a tutorial that utilizes a database (Sakila perhaps?) that actually teaches how to write mySQL commands, AND that has questions for me to answer (via written SQL statements) with the accompanying correct results so I can verify my work. I was hoping for at least a beginning and intermediate mySQL tutorial. But without the correct answers / results, I can't possibly know if the SQL statements I'm writing are correct results or not.
I haven't really seen many tutorials that focus strictly on learning SQL statements and writing scripts, and I've seen none that have a thorough Q&A (with results) section.
If I have to pay for a tutorial, that's fine. I just want to find one that focuses on learning to write SQL statements and scripts and that stays away from configuring and administering type learning.
Any help you can provide is greatly appreciated.
KJ
I started out with an oreilly online course.
I know its not a tutorial, but if you are prepared to pay, its the better choice
For what you get its not that expensive and you'll come out of it with a very strong base.
If you are looking for strictly database:
Database Administration Certificate
Or a mix with a programming language (gives better insight to usage)
PHP/SQL Programming Certificate
Also I found a really nice site with a lot of common and useful sql queries that you can use to learn some neat tricks
Common MySQL Queries
I hope this helps you and good luck
Does anyone know of a quick and easy test to see if a query is properly formatted for both MySQL & MSSQL. Perhaps other database types as well, such as SQL Server? I only have access to MySQL at this time.
Info: I'm working on an Open Source project called JJWDesign Google Maps for SugarCRM. Some of the queries use the SugarCRM classes; others I have to write custom. For example, some are special distance calculations against the geocode information stored in the tables.
http://www.sugarforge.org/projects/jjwgooglemaps/
More importantly, while there is an accepted syntax, each flavour of database has it's own specific functions, features and things you can do.
The best you can do is to make do with the most basic of features. Oracle has different functions for datetime compared to mysql compared to db2. While I would love to assist in a 'free as in beer' project, you really will need to check each function to see if it is the same across all major vendors. General functions most often are, so abs() will be fairly consistent, but others simply won't.
You're talking about a SQL parser so by definition it either isn't going to be quick and easy or it will do only the simplest checking.
Each RDBMS has its own flavour of SQL too so you'd really be limited to testing whether it was ANSI SQL.
I've just been tasked with automating a reporting task at work. Previously, someone would run large, arbitrary SELECTs on a MySQL database using a GUI tool, then use that same tool to export the results to CSV. Now I want to write a Ruby script to do this.
I know about FasterCSV in Ruby, but as far as SQL queries, I've only used ActiveRecord, where you're generally not writing the queries but using models and associations. The last time I wrote out complete SQL in code was when I coded PHP.
What's the most straightforward way to do this sort of thing in Ruby? Should I use ActiveRecord?
If you are writing a complex application, there is absolutely nothing wrong with using ActiveRecord. Especially since you are already comfortable with it.
If you are writing a quick script and don't want to bother with ActiveRecord, you should also check out the mysql and mysql2 gems.
I highly recommend Sequel. It has great documentation, active development, a thriving and helpful community, and it is (IMHO) simpler and better than ActiveRecord, especially for simple use cases like you appear to have.
You might want to start by reading the README, Cheat Sheet and Sequel for SQL Users.
I often find that in reporting engines you end up with complex queries processing large amounts of data and ORMs like ActiveRecord just don't cut it. Unless your reports are really simple, I think you'll want to use raw SQL (with a tool like Sequel) or call stored procedures.
Thus far used sql server stored procedures for all my web applications... Now thought of moving to an ORM... I would like to ask SO users about LINQ to SQL
Is Linq to sql worth a try as a beginner to an ORM?
or should i look for some others... Any suggestion...
EDIT:
I have a sql server 2005 database with all tables....
How to use this db with Linq to sql?
Coming from using ADO.NET table adapters, LINQ was a revelation. A breath of fresh air. The veil was lifted. A new day dawned. And so on and such forth.
Start with Scott Gu's series here and check all his other blogs on the subject.
I envy you your impending joy.
Skip it. Second grade little ORM missing all the interesting features (and don't get me even started with EntityFramework - crap in v1, barely usable in v2).
I suggest getting ahold of NHibernate.
Even though I, unfortunately, don't do much Windows/.NET development anymore, I still think that C#/.NET is the best programming environment around and that Linq is a great ORM. If you're on the .NET/C# platform, use it. There's good documentation, a large community of users to help you, and very solid implementations.
While Microsoft SQL Server doesn't get a lot of buzz, it is a very worthy database to be the platform underlying linq.
If you're just starting, then I recommend you ignore LINQ to SQL. Microsoft will be placing all of their development efforts behind Entity Framework, which is more powerful and general than LINQ to SQL.
Coming from a similar situation I found linq-to-sql worked really well. We previously used a repository pattern and managed to follow it pretty closely with linq to sql in about half the time. Linq-to-Sql will also allow you to write and use regular store procedures.
For a beginner I found the linq-to-sql sections of the Nerd Dinner tutorial a good starting point.
Personally, I think that L2S is a great choice for a ORM beginner because it's really easy to use, but still gives you plenty of power. IMO, if you are doing new SQL Server work, L2S is the best and easiest ORM available. It's not perfect, but neither is anything else out there.
Also, PLINQO adds a lot of the missing features to L2S that bring it more in line with EF, while maintaining the simplicity and speed of L2S.
I hear a lot of linq-to-sql bashing and how people will unknowingly abuse it. But how is linq-to-sql being abused?
Update
If someone can give me clear examples of how it's abused that would be very helpful. References to blogs/tutorials would be very helpful as well.
Thanks.
One of the easiest mistakes to make is to create a query which results in a loop of calls to the database instead of a single call returning all the data. For this reason it's worth checking what sql commands are hitting the database either in the debugger or with a trace.
There are many ways that LINQ->SQL can be abused just like poorly written inline SQL/ADO.NET/SPs or what have you.
Alot of what you might have heard is how LINQ itself might be abused.
I think one example of it being misused would be as a total replacement for SQL in views or stored procedures on the server, and therefore potentially more lax security on the database server.
Well... if you can write complicated queries with linq-to-sql it's probably because you know SQL syntax and are pretty good at writting the query in SQL in the first place. So why would you use the .NET syntax to write a syntax tree that then another layer of software would translate (perhaps not very efficiently) into SQL for you?
Just write the damn thing in SQL in the first place :-)