adiboing Posted November 24, 2010 Share Posted November 24, 2010 Hello guys,its my first time I work with iReport and I have a problem which seems a bit confusing. To get the data out of my database I wrote in the "Report Query" -Window the following query:SELECT ATTACHEDFILE, NID, FILETYPEFROM GekkoATTACHWHERE NID >= 970ORDER BY NID ASCIn ATTACHEDFILE is a Hex-Code for the different files. And the NID is just the id. FILETYPE shows if it is a "pdf" or "jpg". And as you can see I just like to show all files after the ID 970.And now I would like to insert the author who attached the file to the database. But the entry for the author is in another table. So my Query should look like this.SELECT AUTHORFROM GekkoNOTEWHERE NID >= 970ORDER BY NID ASCBut I realy don't know how to get the author from another table to insert it via the fields to my report. I hope you could understand my problem, if not ask again pls.peace Adiboing Link to comment Share on other sites More sharing options...
phantastes Posted November 24, 2010 Share Posted November 24, 2010 Hi,I would recommend reading through one of the many SQL tutorials online. Just google "sql tutorial".In the case you mention you would need to join the two tables. Without knowing how the two table look like I cannot guarantee that this is the right solution, but if NID is the key it would look something like this:Code:SELECT ga.attachedfile, ga.nid, ga.filetype, gn.authorFROM GekkoATTACH gaINNER JOIN GekkoNOTE gn ON ga.nid = gn.nidWHERE ga.nid >= 970ORDER BY ga.nid ASC Link to comment Share on other sites More sharing options...
adiboing Posted November 24, 2010 Author Share Posted November 24, 2010 It works :DI tried the inner join command before but not like your code. But serious why the hell isn't it possible to include several tables in iReport via a few SELECT commands. In my opinion thats a huge gap in the programm.thanks to you, Adi ;) Link to comment Share on other sites More sharing options...
cbarlow3 Posted November 24, 2010 Share Posted November 24, 2010 You could have multiple SQL queries by using a List component or by using SubReports...but you wouldn't get the effect that you're probably after of relating information from one table with information from another table. The standard way of doing that with a relational database is with the various types of JOIN, regardless of what reporting tool you use. It's not a shortcoming of iReport: it's a matter of iReport using the same technique that every other SQL-based tool uses for recombining related information that has been split into separate tables for normalization reasons.Carl Link to comment Share on other sites More sharing options...
phantastes Posted November 24, 2010 Share Posted November 24, 2010 Hi Adi,Like I mentioned before:"I would recommend reading through one of the many SQL tutorials online. Just google "sql tutorial".Your question is related to basic SQL syntax and has nothing to do with iReport.Best of luck! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now